View Code of Problem 96

#include<bits/stdc++.h>
using namespace std;
 
int main() {
    string str;
    int t;
    while (1){
    	cin>>t>>str;
        long long sum=0;
        if (t==0)
            break;
        else{
            
            if (str[0]=='K'){
                sum=t*pow(1024,1)-t*pow(1000,1);
            }
            if (str[0]=='M'){
                sum=t*pow(1024,2)-t*pow(1000,2);
            }
            if (str[0]=='G'){
                sum=t*pow(1024,3)-t*pow(1000,3);
            }
            if (str[0]=='T'){
                sum=t*pow(1024,4)-t*pow(1000,4);
            }
            cout<<sum<<endl;
        }
 
    }
 
    return 0;
}

Double click to view unformatted code.


Back to problem 96