题解 | #Old Bill#
Old Bill
https://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927
#include<iostream> using namespace std; int main() { int n, x, y, z; while (cin >> n >> x >> y >> z) { if (n >= 1 && n <= 99) { int max = 0; //符合题意的火鸡单价中的最高价 int h = 0; int l = 0; for (int i = 1; i <= 9; i++) { //i是最高位模糊数字 for (int j = 0; j <= 9; j++) { //j是最低为模糊数字 int price = 10000 * i + 1000 * x + 100 * y + 10 * z + j; if (price % n == 0 && price / n > max) { max = price / n; h = i; //记录此时的最高位 l = j; //记录此时的最低位 } } } if (h == 0 || max == 0) cout << 0 << endl; //如果没有符合题意的解,就输出一个0 else cout << h << ' ' << l << ' ' << max << endl; } } return 0; }