题解 | Old Bill
Old Bill
https://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927
#include <stdio.h>
using namespace std;
int main(){
int n, x, y, z;
while(scanf("%d %d %d %d", &n, &x, &y, &z) != EOF){
int price = 0, max = 0, i1, j1;
for(int i = 1; i<=9; i++){
for(int j=0; j<=9; j++){
int price = i * 10000 + x * 1000 + y * 100 + z * 10 + j;
if(price % n == 0){
if(max < price / n){
max = price / n;
i1 = i;
j1 =j;
}
}
}
}
if(0 == max){
printf("%d", max);
}
else{
printf("%d %d %d\n", i1, j1, max);
}
}
return 0;
}