#include <iostream> #include <string> #include <cstring> #include <cmath> #include <cstdio> #include <vector> #include <algorithm> #include <cstdlib> #include <queue> using namespace std; int main() { int m, n, t, flag; int i, j, k; long long s1, s2; string str; while (cin >> str && str[0] != '0') { flag = -1; k = str.size(); if (str[k - 2] == 'K') flag = 1; else if (str[k - 2] == 'M') flag = 2; else if (str[k - 2] == 'G') flag = 3; else if (str[k - 2] == 'T') flag = 4; else flag = 0; str.erase( k - 2, 2); m = atoi(str.c_str()); s1 = m * pow(1024, flag); s2 = m * pow(1000, flag); cout << s1 - s2 << endl; } return 0; } |
Double click to view unformatted code.