水题~~~~HDU 4788

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


#include<stdio.h>
#include<string.h>
int change(char *s){
if(!strcmp(s,"[B]")) return 0;
if(!strcmp(s,"[KB]")) return 1;
if(!strcmp(s,"[MB]")) return 2;
if(!strcmp(s,"[GB]")) return 3;
if(!strcmp(s,"[TB]")) return 4;
if(!strcmp(s,"[PB]")) return 5;
if(!strcmp(s,"[EB]")) return 6;
if(!strcmp(s,"[ZB]")) return 7;
if(!strcmp(s,"[YB]")) return 8;
}
int main(){
int t;
scanf("%d",&t);
int s,count=0;
char str[10];
while(t--){
scanf("%d%s",&s,str);
int c=change(str);
double p=1;
while(c--)
p*=1000.0/1024.0;
p=1-p;
printf("Case #%d: %.2f%%\n",++count,p*100);//printf("%%");输出%
}
return 0;
}

时间: 2024-11-05 13:37:09

水题~~~~HDU 4788的相关文章

水题/hdu 1012 u Calculate e

题意 求n=0~9时的sigma(1/n!) 分析 因为刚学c++ 所以对浮点操作还是很不熟练,正好来了这么一道题 Accepted Code 1 /* 2 PROBLEM:hdu 1012 3 AUTHER:Nicole Lam 4 MEMO:水题 5 */ 6 #include<iostream> 7 #include<iomanip> 8 using namespace std; 9 double a[10]; 10 int main() 11 { 12 cout<&l

水题/hdu 1004 Let the Balloon Rise

题意 给出n个字符串,输出出现次数最多的那个 分析 存下字符串后排序,再统计,输出 Accepted Code 1 /* 2 PROBLEM:hdu1004 3 AUTHER:Nicole Lam 4 MEMO:水题 5 */ 6 7 #include<iostream> 8 #include<cstring> 9 #include<string> 10 #include<algorithm> 11 using namespace std; 12 13 in

水题/hdu 1001 Sum Problem

题意 给出一个数n,求1+2+??+n=? 分析 注意多case Accepted Code 1 /* 2 PROBLEM:hdu1001 3 AUTHER:NicoleLam 4 MEMO:水题 5 */ 6 7 #include<cstdio> 8 9 int main() 10 { 11 int n; 12 while (scanf("%d",&n)!=EOF) 13 { 14 int s=0; 15 for (int i=1;i<=n;i++) s+=

水题/hdu 1000 A + B problem

题意 输入a,b,输出a+b: 分析 注意多case Accepted Code 1 /* 2 PROBLEM:hdu1000 3 AUTHER:NicoleLam 4 MEMO:水题 5 */ 6 7 #include<cstdio> 8 int main() 9 { 10 int a,b; 11 while (scanf("%d%d",&a,&b)!=EOF) printf("%d\n",a+b); 12 return 0; 13 }

最短路水题 HDU 1874畅通工程续

Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路.不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多.这让行人很困扰. 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离. Input 本题目包含多组数据,请处理到文件结束. 每组数据第一行包含两个正整数N和M(0<N<200,0<M<1000),分别代表现有城镇的数目和已修建的道路的数目.城镇分别以0-N-1编号.

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 4274 Spy&amp;#39;s Work(水题)

Spy's Work Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1266    Accepted Submission(s): 388 Problem Description I'm a manager of a large trading company, called ACM, and responsible for the

hdu 5210 delete 水题

Delete Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 Description wld有n个数(a1,a2,...,an),他希望进行k次删除一个数的操作,使得最后剩下的n−k个数中有最多的不同的数,保证1≤n≤100,0≤k<n,1≤ai≤n(对于任意1≤i≤n) Input 多组数据(最多100组)对于每组数据:第一行:一个数n表示数的个数接下来一行:

HDU 1862 EXCEL排序 (排序水题)

Problem Description Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input 测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<=100000) 和 C,其中 N 是纪录的条数,C 是指定排序的列号.以下有 N 行,每行包含一条学生纪录.每条学生纪录由学号(6位数字,同组测试中没有重复的学号).姓名(不超过8位且不包含空格的字符串).成绩(闭区间[0, 100]内的整数)组成,每个项目间用1个空格隔开.当读到 N=0 时,全部输入结