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 <bits/stdc++.h>
using namespace std;
const int DIM = 50005;
int frq[DIM];
int convert(long long x, int b) {
int s = 0;
for (; x; x /= b)
s += x % b;
return s;
}
int main(void) {
// freopen("kotrljanje.in", "r", stdin);
// freopen("kotrljanje.out", "w", stdout);
int c, d, b, m;
cin >> c >> d >> b >> m;
for (int i = 1; i; i++) {
int v = convert(1LL * c * i * (b - 1) + d, b);
++frq[v];
if (frq[v] == m) {
for (int j = 1; j <= i; ++j)
if (convert(1LL * c * j * (b - 1) + d, b) == v)
cout << 1LL * j * (b - 1) << " ";
break;
}
}
return 0;
}
# | 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... |