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 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

#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;
}
时间: 2024-11-05 05:07:32

HDOJ 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(数学)

题目链接: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 operati

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 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

[HDOJ4788]Hard Disk Drive(水题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4788 题意:1KB有的时候认为是1000B,有的时候是1024B.问两种方法之间的损失. YY个公式水过. 1 #include <algorithm> 2 #include <iostream> 3 #include <iomanip> 4 #include <cstring> 5 #include <climits> 6 #include <

【HDOJ】1504 Disk Tree

文件可以重名.先按字典序将路径排序,再过滤掉公共前缀.其中的问题是'\'的ASCII比[A-Z0-9]大,将它替换为空格.否则字典序有问题. 1 /* 1504 */ 2 #include <iostream> 3 #include <string> 4 #include <map> 5 #include <queue> 6 #include <set> 7 #include <stack> 8 #include <vector

Get disk drive information

wmic diskdrive get Name, Manufacturer, Model, InterfaceType, MediaType, SerialNumber The full list of properties that you can use for the query above is as follows:?Availability?BytesPerSector?Capabilities?CapabilityDescriptions?Caption?CompressionMe

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