题解 | #Old Bill#
Old Bill
https://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927
#include <csetjmp>
#include <ios>
#include <iostream>
#include <ostream>
using namespace std;
int main() {
int n, x, y, z;
while (cin >> n) {//连续输入用这个
cin >> x >> y >> z;
int i, j;
int tag = 0;//标记这种情况是否成立
int total = 0;
for (i = 9; tag == 0 && i > 0; i--) {
for (j = 9; tag == 0 && j >= 0; j--) {
total = j + z * 10 + y * 100 + x * 1000 + i * 10000;
if (total % n == 0) tag = 1;
}
}
if (tag==1) {
cout << ++i << " " << ++j << " " << total / n << endl;
}else {
cout<<"0"<<endl;
}
}
}
// 64 位输出请用 printf("%lld")

查看1道真题和解析