hdu 4788 Hard Disk Drive (水题)
2014-11-08 15:48
288 查看
题意:
[align=left]Input[/align]
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.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
2 100[MB] 1[B]
[align=left]Sample Output[/align]
Case #1: 4.63% Case #2: 0.00%
代码:
[align=left]Input[/align]
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.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
2 100[MB] 1[B]
[align=left]Sample Output[/align]
Case #1: 4.63% Case #2: 0.00%
代码:
int T; char s[100]; ll Pow(int a,int x){ ll res = 1; rep(i,1,x) res *= (ll)a; return res; } int main(){ cin >> T; rep(t,1,T){ scanf("%s",s); int l = strlen(s); char x = s[l-3]; int a; switch(x){ case '[': a=0; break; case 'K': a=1; break; case 'M': a=2; break; case 'G': a=3; break; case 'T': a=4; break; case 'P': a=5; break; case 'E': a=6; break; case 'Z': a=7; break; case 'Y': a=8; break; } ll A = Pow(125,a), B = Pow(128,a); //printf("%I64d %I64d\n",A,B); double ans = (double)100 - ((double)A*100/(double)B); printf("Case #%d: %.2lf%%\n",t,ans); } }
相关文章推荐
- HDU 4788 Hard Disk Drive (水题)
- HDU 4788 Hard Disk Drive (2013成都H,水题)
- HDU - 4788 Hard Disk Drive (成都邀请赛H 水题)
- hdu 4788 Hard Disk Drive
- HDU 4788 Hard Disk Drive
- HDU 4788——Hard Disk Drive
- HDU——4788 Hard Disk Drive
- [HDOJ4788]Hard Disk Drive(水题)
- hdu 4788 Hard Disk Drive
- hdu 4788 Hard Disk Drive
- HDU-4788 Hard Disk Drive(java)
- HDU 4788 Hard Disk Drive(数学)
- HDU_4788_Hard Disk Drive(打表)(13成都现场H题)
- HDU 4788 Hard Disk Drive(2013亚洲区成都站现场赛)
- HDU-#4788 Hard Disk Drive
- SDKD-训练题-HDU-4788-Hard Disk Drive-模拟
- hdu 4788 Hard Disk Drive
- 文章标题 HDU 4788 : Hard Disk Drive (水)
- hdu 4788 Hard Disk Drive
- HDU 4788 Hard Disk Drive