B1037 在霍格沃茨找零钱 (20 分)

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
    
    
	int a, b, c;
	int x, y, z;
	
	int z1, z2, z3;
	
	scanf("%d.%d.%d %d.%d.%d", &a, &b, &c, &x, &y, &z);
	
	z1 = a * 17 * 29 + b * 29 + c;
	z2 = x * 17 * 29 + y * 29 + z;
	
	z3 = z2 - z1;
		a = z3 / (17 * 29);
		b = z3 % (17 * 29) / 29;
		c = z3 - (17 * 29 * a + 29 * b);
	if(z3 >= 0) {
    
    
		printf("%d.%d.%d", a, b, c);
	} else  {
    
    
		printf("%d.%d.%d", a, -b, -c);
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/alovelypeach/article/details/113971858