题解 | #Old Bill#
Old Bill
https://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927
// the old bill #include <iostream> int main() { int N; //number of turkeys while (scanf("%d", &N) == 1) { int X, Y, Z; scanf("%d %d %d", &X, &Y, &Z); int MSB, LSB, price = 0; //two faded numbers for (int i = 1; i <= 9; i++) { for (int j = 0; j <= 9; j++) { float aTurkeyPrice = (float)(i * 10000 + X * 1000 + Y * 100 + Z * 10 + j) / N; int intPrice = (int)aTurkeyPrice; float fPrice = (float)intPrice; if (aTurkeyPrice == fPrice) MSB = i, LSB = j, price = intPrice; } } if (price == 0) printf("0\n"); else printf("%d %d %d\n", MSB, LSB, price); } }