hdu 4788 Hard Disk Drive

        题意:计算在不同单位(B、KB、MB、GB......)下,1000进制和1024进制实际相差多少。

        思路:按照定义计算。


#include <iostream>         
#include <stdio.h>         
#include <cmath>         
#include <algorithm>         
#include <iomanip>         
#include <cstdlib>         
#include <string>         
#include <string.h>         
#include <vector>         
#include <queue>         
#include <stack>         
#include <map>       
#include <set>       
#include <ctype.h>         
#include <sstream>     
#define INF 1000000000     
#define ll long long     
#define min3(a,b,c) min(a,min(b,c))  
#define max3(a,b,c) max(a,max(b,c)) 

using namespace std;

int main(){
	int t;
	cin>>t;
	string str;
	int cas=0;
	while(t--){
		cas++;
		cin>>str;
		int len=str.size();
		
		int y=0;
		if(str[len-3]=='K'){
			y=1;
		}else if(str[len-3]=='M'){
			y=2;
		}else if(str[len-3]=='G'){
			y=3;
		}else if(str[len-3]=='T'){
			y=4;
		}else if(str[len-3]=='P'){
			y=5;
		}else if(str[len-3]=='E'){
			y=6;
		}else if(str[len-3]=='Z'){
			y=7;
		}else if(str[len-3]=='Y'){
			y=8;
		}
		
		double x=1000.0/1024.0;
		double z=pow(x,y);
		printf("Case #%d: %.2lf%%\n",cas,100*(1-z));
	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值