1037 在霍格沃茨找零钱 (20 分)
作者:互联网
#include <iostream> #include <cmath> using namespace std; int main() { char c; int g1, g2, s1, s2, k1, k2; cin >> g1 >> c >> s1 >> c >> k1; cin >> g2 >> c >> s2 >> c >> k2; int p1 = g1 * 17 * 29 + s1 * 29 + k1; int p2 = g2 * 17 * 29 + s2 * 29 + k2; int t = p2 - p1; if (t < 0) {。 // 巧妙的设置,可以节省很多 t = abs(t); cout << '-'; } int a = t / 493; //简单的转换注意一下 int b = t % 493 / 29; int d = t % 493 % 29; cout << a << '.' << b << '.' << d << endl; return 0; }
标签:沃茨,20,int,s2,s1,29,k2,k1,霍格 来源: https://www.cnblogs.com/Hk456/p/10759112.html