timus 1572. Yekaterinozavodsk Great Well URAL 解題報告
又是計算幾何小水題,入門長信心啊!
題目大意: 一共三種類型的井蓋,圓,正方形,等邊三角形;然後一個大坑,也是哪三種類型裏面的一種;
問有多少個井蓋小到能放到大坑裏;
思路:用井蓋最窄的地方和坑最寬的地方作比較;然後計數 ……
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#include<iostream>
#define MAXSIZE 100
#define EPS 1e-6
const double pi=acos(-1.0);
using namespace std;
double f(int x,int l,int cmd)
{
if(cmd==0)///保留寬的
{
if(x==1)return 2*l;
else if(x==2) return sqrt(2.0)*l;
else if(x==3) return l;
}
else if(cmd==1)
{///保留窄的
if(x==1)return 2*l;
else if(x==2) return l;
else if(x==3) return cos(1.0*pi/6.0)*l;
}
}
int main()
{
int n;
double x0;
int cmd;
cin>>cmd>>x0;
x0=f(cmd,x0,0);
cin>>n;
double tmp;
int ans=0;
for(int i=0;i<n;++i)
{
cin>>cmd>>tmp;
if(f(cmd,tmp,1)>x0)continue;
ans++;
}cout<<ans<<endl;
return 0;
}