#include<stdio.h> #include<string.h> #include<math.h> int main(){ int n; char s[3]; //printf("%d%s",n,s); while(scanf("%d%s",&n,s)!=EOF){ long long int sub=0; if(n==0){ break; } if(strcmp(s,"MB")==0){ sub=n*(pow(1024,2)-pow(1000,2)); printf("%lld\n",sub); }else if(strcmp(s,"kB")==0){ sub=n*(pow(1024,1)-pow(1000,1)); printf("%lld\n",sub); }else if(strcmp(s,"GB")==0){ sub=n*(pow(1024,3)-pow(1000,3)); printf("%lld\n",sub); }else if(strcmp(s,"TB")==0){ sub=n*(pow(1024,4)-pow(1000,4)); printf("%lld\n",sub); } } return 0; } |
Double click to view unformatted code.