0%

奶牛硬盘

题意

  • 硬盘的制造商认为”一千” 是1000,但是操作系统认为”一千”是1024.单位分别有“B”, “KB”, “MB”, “GB”, “TB”, “PB”, “EB”, “ZB”, “YB”

分析

  1. 很简单的一道题,只和单位有关系和前面数值没关系,先求出保存率,然后1-保存率,base[0]= 1, base[1] = (1000)/1024;…

思考

  1. 我在想0MB的丢失百分比是多少???我反正没考虑直接过了
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*************************************************************************
> File Name: m.cpp
> Author: liangxianfeng
> Mail: 641587852@qq.com
> Created Time: 2016年05月09日 星期一 13时15分32秒
************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
using namespace std;
#define ll long long
#define rep(i,n) for(int i =0; i < n; ++i)
#define CLR(x) memset(x,0,sizeof x)
#define MEM(a,b) memset(a,b,sizeof a)
#define pr(x) cout << #x << " = " << x << " ";
#define prln(x) cout << #x << " = " << x << endl;
const int maxn = 4e5+100;
const int INF = 0x3f3f3f3f;
double ans[10];
char s[1000];
string sz[]={"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
int main(){
#ifdef LOCAL
freopen("/home/zeroxf/桌面/in.txt","r",stdin);
//freopen("/home/zeroxf/桌面/out.txt","w",stdout);
#endif
int t, kase = 0;
scanf("%d", &t);
ans[0] = 1;
ans[1] = 1000.0/1024;
for(int i = 2; i < 9; ++i){
ans[i] = ans[i-1]*ans[1];
}
while(t--){
scanf("%s", s);
int l = 0, r = 0;
string str;
int len = strlen(s);
for(int i = 0; i < len; ++i){
if(s[i] == '[') l = i;
if(s[i] == ']') r = i;
}
for(int i = l+1; i < r; ++i){
str += s[i];
}
int pos = 0;
for(int i = 0; i < 9; ++i){
if(str == sz[i]) pos = i;
}
printf("Case #%d: %.2f%\n", ++kase,(100.0 - ans[pos]*100));
}
return 0;
}