题解 | #Old Bill#
Old Bill
https://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927
#include<cstdio> int main() { int n, x, y, z; scanf("%d\n %d %d %d", &n, &x, &y, &z); int a, b,price; int max=0,maxa,maxb; for (a = 1; a <= 9; ++a) { for (b = 0; b <= 9; ++b) { price=a * 10000 + x * 1000 + y * 100 + z * 10 + b; if(price % n == 0 && price>=(max*n)) { max=price/n; maxa=a; maxb=b; } } } if(max==0) { printf("%d",0); } else { printf("%d %d %d\n", maxa, maxb, max); } return 0; }