#include<iostream> #include<algorithm> #include<math.h> #include<stdio.h> #include<stdlib.h> #include<string.h> #include<cstring> #include<string> #include<sstream> #include<vector> #include<map> #define ll long long using namespace std; int main() { ll num; char c; map<char,int> m; m['K']=1; m['M']=2; m['G']=3; m['T']=4; while(scanf("%lld%cB",&num,&c)!=EOF) { if(num==0) return 0; else { ll x,y,sum; x=num*pow(1024,m[c]); y=num*pow(1000,m[c]); sum=x-y; printf("%lld\n",sum); } } return 0; } |
Double click to view unformatted code.