• 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): 125    Accepted Submission(s): 75

    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
     
    Recommend
    We have carefully selected several similar problems for you:  4790 4789 4787 4786 4785 
     
    思路:水题
     
    代码:
    #include <iostream>
    #include <cstring>
    #include <cstdio>
    #include <cmath>
    #include <algorithm>
    #include <queue>
    using namespace std;
    int t;
    int the_number;
    double sum;
    int the_flag;
    double the_result;
    char map[10];
    char str;
    int main()
    {
        scanf("%d",&t);
        for(int k = 1;k <= t;k ++)
        {
            memset(map,0,sizeof(map));
            the_flag = 0;
            the_number = 0;
            sum = 1;
            the_result = 0;
            scanf("%s",map);
            int m = 1;
            for(int i = 0;i < 10;i ++)
            {
                if(map[i] == '[')
                {
                    str = map[i + 1];
                    break ;
                }
                the_number = the_number * m + map[i] - '0';
                m = 10;
            }
            printf("Case #%d: ",k);
            if(str == 'B')
               the_flag = 0;
            if(str == 'K')
               the_flag = 1;
            if(str == 'M')
               the_flag = 2;
            if(str == 'G')
               the_flag = 3;
            if(str == 'T')
               the_flag = 4;
            if(str == 'P')
               the_flag = 5;
            if(str == 'E')
               the_flag = 6;
            if(str == 'Z')
               the_flag = 7;
            if(str == 'Y')
               the_flag = 8;
            if(the_flag == 0)
            {
                printf("0.00");
                printf("%%
    ");
            }
            else
            {
                while(the_flag --)
                {
                    sum = sum * (1000.0 / 1024.0);
                }
                the_result = (1 - sum) * 100;;
                printf("%.2lf",the_result);
                printf("%%
    ");
            }
        }
        return 0;
    }
  • 相关阅读:
    poj 3264 Balanced Lineup
    poj 2762 Going from u to v or from v to u?
    hdu 3671 Boonie and Clyde
    zoj 3195 Design the city
    poj 1523 SPF
    Codeforces Polo the Penguin and Matrix
    MVC原理的简述(转)
    C#访问权限修饰符
    XML Schema介绍
    Sql批量删除/插入
  • 原文地址:https://www.cnblogs.com/GODLIKEING/p/3432542.html
Copyright © 2020-2023  润新知