HDU 4788 Hard Disk Drive (2013成都H,水题)
发布日期:2021-08-31 16:58:48 浏览次数:6 分类:技术文章

本文共 2818 字,大约阅读时间需要 9 分钟。

Hard Disk Drive

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 83    Accepted Submission(s): 48

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
 

 

 

水题一枚。。。。胡搞就行

 

1 /* *********************************************** 2 Author        :kuangbin 3 Created Time  :2013-11-16 12:58:01 4 File Name     :E:\2013ACM\专题强化训练\区域赛\2013成都\1008.cpp 5 ************************************************ */ 6  7 #include 
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 #include
16 #include
17 #include
18 #include
19 using namespace std;20 21 int change(char s[])22 {23 if(strcmp(s,"B]") == 0)return 0;24 if(strcmp(s,"KB]") == 0)return 1;25 if(strcmp(s,"MB]") == 0)return 2;26 if(strcmp(s,"GB]") == 0)return 3;27 if(strcmp(s,"TB]") == 0)return 4;28 if(strcmp(s,"PB]") == 0)return 5;29 if(strcmp(s,"EB]") == 0)return 6;30 if(strcmp(s,"ZB]") == 0)return 7;31 if(strcmp(s,"YB]") == 0)return 8;32 }33 34 char s[100];35 int main()36 {37 //freopen("in.txt","r",stdin);38 //freopen("out.txt","w",stdout);39 int T;40 int iCase = 0;41 double a;42 scanf("%d",&T);43 while(T--)44 {45 iCase++;46 scanf("%lf[%s",&a,s);47 int t = change(s);48 double ans = pow(1000.0,t)/pow(1024.0,t);49 ans = 1-ans;50 printf("Case #%d: %.2lf%%\n",iCase,ans*100);51 52 53 }54 return 0;55 }

 

 

 

 

转载地址:https://blog.csdn.net/weixin_34082789/article/details/85592794 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:打印所在函数和行数的调试技术
下一篇:[转]分享一套抓数据小程序,客户资料、实时新闻、股票数据…随心抓

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月06日 11时16分57秒