zoukankan      html  css  js  c++  java
  • 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 }
     
     
     
     
     
     
     
  • 相关阅读:
    KVM虚拟机高级设置——09 设置KVM虚拟机开机自动启动
    KVM虚拟机高级设置——08 管理远程虚拟机
    搭建KVM环境——07 带GUI的Linux上安装KVM图形界面管理工具
    搭建KVM环境——06 创建虚拟机
    TightVNC安装
    数据库设计
    Free lunch is over
    【问题】使用XShell连接Debian,没有语法高亮
    【Intel 汇编】ELF文件
    【问题】No manual entry for pthread_create in section 3
  • 原文地址:https://www.cnblogs.com/haoabcd2010/p/6171378.html
Copyright © 2011-2022 走看看