zoukankan      html  css  js  c++  java
  • Gym 100733C

    题目:

      

    Even though he is the head of the Shitalian Mafia, Shi doesn't like bloodshed and punishes his subordinates if they kill innocent people. That is why the death report is always written in the following way: "We killed x% of the innocent people".

    Shi wants to know the smallest number of innocent people that must have been in that place so that exactlyx% of the innocent people have died.

    For instance, if we have x = 35%. In this case we had 20 people, and 7 were victims, because 35% of 20 is 7. That is the minimum possible.

    Input

    There is a single number 0 ≤ x ≤ 100 with at most 15 decimal places.

    Output

    Print the number sought by Shi.

    Sample Input

    Input
    35
    Output
    20
    Input
    50.0
    Output
    2
    Input
    7.500
    Output
    40
    Input
    35.123456789
    Output
    100000000000
    题意:
    给你一个百分数,让你求一个最小数,使得这个最小的整数乘以这个百分数后可以得到一个整数
    分析:
    把给定的数存为字符串,使得可以计算出移动小数点多少位后(k),可以使的给的实数变为整数,然后分子分母通扩大k倍,然后乱搞。。。。
     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<cmath>
     5 using namespace std;
     6 typedef long long LL;
     7 char num[20];
     8 LL a[20];
     9 LL gcd(LL a,LL b)
    10 {
    11     return b==0? a:gcd(b,a%b);
    12 }
    13 int main()
    14 {
    15     scanf("%s",num);
    16     int n=strlen(num);
    17     //printf("n==%d\n",n);
    18     int k=0;
    19     for(int i=0;i<n;i++)
    20     {
    21         if(num[i]=='.')
    22         {
    23             k=n-i-1;
    24             break;
    25         }
    26     }
    27     //printf("%d\n",k);
    28     LL cnt=0;
    29     for(int i=0;i<n;i++)
    30     {
    31         if(num[i]=='.') continue;
    32         else
    33         cnt=cnt*10+(num[i]-'0');
    34         //printf("cnt==%lld\n",cnt);
    35     }
    36     //printf("%lld\n",cnt);
    37     LL m=100;
    38     for(int i=1;i<=k;i++)
    39     {
    40         m=m*10;
    41     }
    42     //printf("m=%lld\n",m);
    43     LL ans=gcd(cnt,m);
    44     //printf("%lld\n",ans);
    45     printf("%lld\n",m/ans);
    46     return 0;
    47 }
  • 相关阅读:
    缩点【洛谷P1262】 间谍网络
    模板-割点
    Tarjan缩点+LCA【洛谷P2416】 泡芙
    模拟赛 10-20考试记
    BFS【bzoj1667】: [Usaco2006 Oct]Cows on Skates滑旱冰的奶牛
    最短路【bzoj2464】: 中山市选[2009]小明的游戏
    linux /dev/mapper/centos-root 被占满
    Centos7中安装Mysql8并修改密码策略并远程连接
    Centos7中PHP编译安装mysqli扩展报错
    Linux中Composer 在安装依赖包与本地php版本不符问题
  • 原文地址:https://www.cnblogs.com/forwin/p/4807001.html
Copyright © 2011-2022 走看看