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

 

转载于:https://www.cnblogs.com/mengchunchen/p/4852287.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值