#include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ ios::sync_with_stdio(false); string input, tmp; int length, checkNum; long long num, numTmp; while(cin >> input){ length = input.length(); tmp = input.substr(0, length-2); checkNum = atoi(tmp.c_str()); if(checkNum == 0) break; tmp = input.substr(length-2, length); if(tmp == "TB"){ num = 1024; num *= 1024; num *= 1024; num *= 1024; numTmp = 1000; numTmp *= 1000; numTmp *= 1000; numTmp *= 1000; num -= numTmp; } else if(tmp == "GB"){ num = 1024*1024*1024-(1000*1000*1000); } else if(tmp == "MB"){ num = 1024*1024-(1000*1000); } else if(tmp == "KB"){ num = 1024-1000; } cout << checkNum*num << endl; } return 0; } |
Double click to view unformatted code.