hdu 1701

http://acm.hdu.edu.cn/showproblem.php?pid=1701

刚开始没看懂题意,不过后来看看别人的才明白,原来是至少的人数必须之多的人数少,以这个作为标度进行逻辑;

代码如下:

#include"stdio.h"

int main( )
{
    int t,i;
    double p,q;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lf%lf",&p,&q);
        for(i=1;;i++)
        {
            if((int)(p*i/100)<(int)(q*i/100)) //注意这里浮点数引起的误差。
                break;  
        }
        printf("%d\n",i);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/chaosheng/p/2511526.html