Hdoj 4788 hard disk drive

Source: Internet
Author: User

Python3 tables ....


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 100 MB 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 95 MB. the 5 MB 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 cocould 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 shocould be rounded to two digits after the decimal point.
Sample Input
2100[MB]1[B]
 
Sample output
Case #1: 4.63%Case #2: 0.00%Hint 
 
Source2013 Asia Chengdu Regional Contest

#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char xxx[9]={'B','K','M','G','T','P','E','Z','Y'};double ans[9]={0.0000,0.0234375,0.0463256,               0.0686774,0.090505,0.111821,               0.132638,0.1529670,0.172819};int main(){    int T_T,cas=1;    scanf("%d",&T_T);    while(T_T--)    {        char op[50],SG;        scanf("%s",op);        for(int i=0;;i++)        {            if(op[i]=='[')            {                SG=op[i+1];                break;            }        }        for(int i=0;i<9;i++)        {            if(SG==xxx[i])            {                printf("Case #%d: %.2lf%%\n",cas++,ans[i]*100.);                break;            }        }    }    return 0;}



Hdoj 4788 hard disk drive

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.