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