Conductors(水题)

Conductors

Background

Everyone making translations from English to Russian knows an English phrase "Naked conductor runs along the bus". It has two very different meanings.

Problem

Every bus in the Ekaterinburg city has a special man (or woman) called conductor. When you ride the bus, you have to give money to the conductor. We know that there are more than P% conductors and less than Q% conductors of all citizens of Ekaterinburg. Your task is to determine a minimal possible number of Ekaterinburg citizens. By percentage, we know that there are more than P% conductors and less than Q% conductors of all Russian citizens in this city

Input

Two numbers PQ such that 0.01 ≤ PQ ≤ 99.99. Numbers are given with 2 digits precision. These numbers are separated by some spaces or "end of line" symbols.

Output

The minimal number of Ekaterinburg citizens.

Example

inputoutput
13
14.1
15

Notes

If there are 15 citizens and 2 conductors among them in Ekaterinburg, then there are 13 1/3 % conductors of all citizens.
 
 
 
//简单的题目,意思就是要 n 个售票员,all 是总人口 % < n / all * 100% < r % 问,满足这公式需要的最少的总人口是多少
要注意的其实就是 浮点数的比较,一般认为,两浮点数相差大于 10e-8 就认为不同了
 1 #include <stdio.h>
 2 #include <math.h>
 3 
 4 int main()
 5 {
 6     double p,q;
 7     double l,r;
 8     while (scanf("%lf%lf",&p,&q)!=EOF)
 9     {
10         for (int i=1;i<=100000;i++)
11         {
12             l=i*p/100;
13             r=i*q/100;
14             int L=floor(l);
15             int R=floor(r);
16             if (R-L>=1&&fabs(l-L)>1e-6&&fabs(r-R)>1e-6)
17             {
18                 printf("%d
",i);
19                 break;
20             }
21         }
22     }
23     return 0;
24 }
 
 
 
 
 
 
 
原文地址:https://www.cnblogs.com/haoabcd2010/p/6171378.html