HDU 4788 Hard Disk Drive(数学)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4788

Problem Description

  Yesterday your dear cousin Coach Pang gave you a new 100MB hard disk drive (HDD) as a gift because you will get married next year.

  But you turned on your computer and the operating system (OS) told you the HDD is about 95MB. The 5MB of space is missing. It is known that the HDD manufacturers have a different capacity measurement. The manufacturers think 1 “kilo” is 1000 but the OS thinks
that is 1024. There are several descriptions of the size of an HDD. They are byte, kilobyte, megabyte, gigabyte, terabyte, petabyte, exabyte, zetabyte and yottabyte. Each one equals a “kilo” of the previous one. For example 1 gigabyte is 1 “kilo” megabytes.

  Now you know the size of a hard disk represented by manufacturers and you want to calculate the percentage of the “missing part”.

Input

  The first line contains an integer T, which indicates the number of test cases.

  For each test case, there is one line contains a string in format “number[unit]” where number is a positive integer within [1, 1000] and unit is the description of size which could be “B”, “KB”, “MB”, “GB”, “TB”, “PB”, “EB”, “ZB”, “YB” in short respectively.

Output

  For each test case, output one line “Case #x: y”, where x is the case number (starting from 1) and y is the percentage of the “missing part”. The answer should be rounded to two digits after the decimal point.

Sample Input

2
100[MB]
1[B]

Sample Output

Case #1: 4.63%
Case #2: 0.00%

Hint


Source

2013 Asia Chengdu Regional Contest

PS:

求一个单位相差分别是1000和1024的差值!

见案例!

代码如下:

#include <cstdio>
#include <cstring>
int findd(char s[])
{
    int len = strlen(s);
    if(len <= 3)
        return 0;
    if(s[1] == 'K')
        return 1;
    if(s[1] == 'M')
        return 2;
    if(s[1] == 'G')
        return 3;
    if(s[1] == 'T')
        return 4;
    if(s[1] == 'P')
        return 5;
    if(s[1] == 'E')
        return 6;
    if(s[1] == 'Z')
        return 7;
    if(s[1] == 'Y')
        return 8;
}
int main()
{
    int t;
    int num;
    char s[7];
    int cas = 0;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%s",&num,s);
        int k = findd(s);
        if( k == 0)
        {
            printf("Case #%d: 0.00%%\n",++cas);
            continue;
        }
        double t1 = 1.0, t2 = 1;
        for(int i = 0; i < k; i++)
        {
            t1*=(1000.0/1024.0);
        }
//        printf("%.2lf\n",t1);
        printf("Case #%d: %.2lf%%\n",++cas,(1-(t1/t2))*100.0);
    }
    return 0;
}
时间: 2024-10-14 16:43:22

HDU 4788 Hard Disk Drive(数学)的相关文章

HDU 4788 Hard Disk Drive

题目链接:HDU 4788 Hard Disk Drive 题面: Hard Disk Drive Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1872    Accepted Submission(s): 1028 Problem Description Yesterday your dear cousin Coach Pang

HDU - 4788 Hard Disk Drive (成都邀请赛H 水题)

HDU - 4788 Hard Disk Drive Time Limit:1000MS   Memory Limit:32768KB   64bit IO Format:%I64d & %I64u [Submit]  [Go Back]  [Status] Description Yesterday your dear cousin Coach Pang gave you a new 100MB hard disk drive (HDD) as a gift because you will

HDU 4788 Hard Disk Drive (2013成都H,水题) 进位换算

1 #include <stdio.h> 2 #include <algorithm> 3 #include <string.h> 4 #include<cmath> 5 using namespace std; 6 double a; 7 char s[100]; 8 int fun(char s[]) { 9 if(strcmp(s,"B]") == 0)return 0; 10 if(strcmp(s,"KB]"

HDOJ 4788 Hard Disk Drive

Python3打表.... Hard Disk Drive Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1044    Accepted Submission(s): 564 Problem Description Yesterday your dear cousin Coach Pang gave you a new 100MB

HDOJ Hard Disk Drive 4788【2013成都区域赛H题-水】

Hard Disk Drive Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1887    Accepted Submission(s): 1042 Problem Description Yesterday your dear cousin Coach Pang gave you a new 100MB hard disk dri

HDU 4788 (14.05.12)

Hard Disk Drive Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 647    Accepted Submission(s): 350 Problem Description Yesterday your dear cousin Coach Pang gave you a new 100MB hard disk drive

HDU 4405 飞行棋上的数学期望

突然发现每次出现有关数学期望的题目都不会做,就只能找些虽然水但自己还是做不出的算数学期望的水题练练手了 题目大意: 从起点0点开始到达点n,通过每次掷色子前进,可扔出1,2,3,4,5,6这6种情况,扔到几前进几,当然对应飞行通道可以通过x直达一点y,x<y,计算到达n点或超过n 点要扔色子的次数的数学期望 从某一点 i 扔完色子可到达 i+1,i+2,i+3,i+4,i+5,i+6这6个点,令dp[i]为到达末尾的数学期望 那么到达之后6个点的数学期望是一样的,那么dp[i]=dp[i+1]*

hdu 4869 Turn the pokers(数学)

题目链接:hdu 4869 Turn the pokers 题目大意:给定n和m,表示有n次翻牌的机会,m张牌,一开始所有的牌均背面朝上,每次翻牌可以选择xi张牌同时翻转.问说最后有多少种能. 解题思路:只要确定最后正面朝上的牌的个数即可.所以在读入xi的时候维护上下限即可. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long l

HDU 4569 Special equations(数学推论)

题目 //想不出来,看了解题报告 /* 题意:给你一个最高幂为4的一元多项式,让你求出一个x使其结果模p*p为0. 题解:f(x)%(p*p)=0那么一定有f(x)%p=0,f(x)%p=0那么一定有f(x+p)%p=0. 所以我们可以开始从0到p枚举x,当f(x)%p=0,然后再从x到p*p枚举,不过每次都是+p,找到了输出即可,没有的话No solution! */ #include<stdio.h> int main() { int t,n; __int64 a[5],p; scanf(