题解 | #Old Bill#
Old Bill
https://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927
#include <iostream> #include <algorithm> using namespace std; int main() { int N, fade_1, fade_2; int X, Y, Z, total; while (cin >> N) { cin >> X >> Y >> Z; int val = 0; int sum = 0; int total = 0; for (int total = 99999; total >= 1; total--) { if (total % N == 0) { int t = total / N; if ((total / 10) % 10 == Z && (total / 100) % 10 == Y && (total / 1000) % 10 == X) { if (val < t) { sum = total; val = t; } } } } fade_1 = sum / 10000; fade_2 = sum % 10; if (val == 0) { printf("0"); } else if (fade_1 == 0) { printf("0"); } else printf("%d %d %d", fade_1, fade_2, val); puts(""); } }