hdu 4788 (2013成都现场赛 H题)

100MB=10^5KB=10^8B

100MB=100*2^10KB=100*2^20B

Sample Input
2
100[MB]
1[B]

Sample Output
Case #1: 4.63%
Case #2: 0.00%

 

 1 # include <iostream>
 2 # include <cstdio>
 3 # include <cstring>
 4 # include <algorithm>
 5 # include <string>
 6 # include <cmath>
 7 # include <queue>
 8 # include <list>
 9 # define LL long long
10 using namespace std ;
11 
12 char s[100];
13 
14 int change(char s[])
15 {
16     if(strcmp(s,"B]") == 0)return 0;
17     if(strcmp(s,"KB]") == 0)return 1;
18     if(strcmp(s,"MB]") == 0)return 2;
19     if(strcmp(s,"GB]") == 0)return 3;
20     if(strcmp(s,"TB]") == 0)return 4;
21     if(strcmp(s,"PB]") == 0)return 5;
22     if(strcmp(s,"EB]") == 0)return 6;
23     if(strcmp(s,"ZB]") == 0)return 7;
24     if(strcmp(s,"YB]") == 0)return 8;
25 }
26 
27 
28 int main()
29 {
30     //freopen("in.txt","r",stdin) ;
31     int T ;
32     scanf("%d" , &T) ;
33     int Case = 0 ;
34     while(T--)
35     {
36         Case++ ;
37         int x ;
38         scanf("%d[%s" , &x , s) ;
39         int t = change(s) ;
40         double ans = pow(1000.0,t)/pow(1024.0,t) ;
41         ans = 1 - ans ;
42         printf("Case #%d: %.2lf%%\n",Case,ans*100);
43 
44     }
45 
46     return 0;
47 }
View Code

 

posted @ 2015-10-02 15:30  __Meng  阅读(145)  评论(0编辑  收藏  举报