AcWing 3478. 旧帐单
原题链接
简单
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 1e6 + 10;
int t, n, m, k, l, r, op, x, y, z, ans;
int f[N];
bool flag;
void solve() {
while (cin >> n) {
cin >> x >> y >> z;
flag = false;
for (int i = 9; i >= 1; i--) {
for (int j = 9; j >= 0; j--) {
ans = i * 10000 + x * 1000 + y * 100 + z * 10 + j;
if (ans % n == 0) {
l = i;
r = j;
flag = true;
break;
}
}
if (flag) {
break;
}
}
if (flag) {
cout << l << " " << r << " " << ans/n;
} else {
cout << 0;
}
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}