URAL 1572

一开始没有将他当作一个三维视角审视的题目,各种平面分析感觉是不是有点繁琐。。。

后来被大神点播一下发现。。。的确竟然可以直接用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;
}












  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值