#include<iostream> #include<string> #include<math.h> using namespace std; int main(){ long long n; string a; while(cin>>n>>a){ long long s; if(n==0)break; if(a=="B")cout<<"0"<<endl; else if(a=="KB"){ s=n*pow(1024,1)-n*pow(1000,1); } else if(a=="MB"){ s=n*pow(1024,2)-n*pow(1000,2); }else if(a=="GB"){ s=n*pow(1024,3)-n*pow(1000,3); }else if(a=="TB"){ s=n*pow(1024,4)-n*pow(1000,4); } cout<<s<<endl; } return 0; } |
Double click to view unformatted code.