一开始没有将他当作一个三维视角审视的题目,各种平面分析感觉是不是有点繁琐。。。
后来被大神点播一下发现。。。的确竟然可以直接用get_max and get_min这样的过程轻松比较
我还是太连清了
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
using namespace std;
const double eps=1e-10;
double get_max(int type,double length)
{
if(type==1)return 2*length;
if(type==2)return sqrt(2)*length;
return length;
}
double get_min(int type ,double length)
{
if(type==1)return 2*length;
if(type==3)return sqrt(3)*length/2;
return length;
}
int dcmp(double x)
{
if(x>eps)return 1;
if(x<-eps)return -1;
return 0;
}
int n,cnt;
int type;
double length,hull,object;
int main()
{
while(~scanf("%d%lf",&type,&length)){
hull=get_max(type,length);
cnt=0;
scanf("%d",&n);
while(n--){
scanf("%d%lf",&type,&length);
object=get_min(type,length);
if(dcmp(hull-object)>=0)cnt++;
}
printf("%d\n",cnt);
}
return 0;
}