This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <queue>
#include <fstream>
#include <algorithm>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
const ll oo = 1e18;
ll c, d, b, m, cnt[N];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> c >> d >> b >> m;
int p = 1;
while (1) {
ll v = c * p + d;
int sm = 0;
while (v > 0) {
sm += v % b;
v /= b;
}
cnt[sm]++;
if (cnt[sm] == m) {
for (int i = 0; i <= p; ++i) {
ll v2 = c * i + d;
int sm2 = 0;
while (v2 > 0) {
sm2 += v2 % b;
v2 /= b;
}
if (sm2 == sm)
cout << i << ' ';
}
break;
}
p++;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |