#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 |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
98 ms |
2972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
2476 KB |
Output is correct |
2 |
Correct |
68 ms |
2424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
2424 KB |
Output is correct |
2 |
Correct |
76 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
2540 KB |
Output is correct |
2 |
Correct |
81 ms |
2680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
2704 KB |
Output is correct |
2 |
Correct |
204 ms |
2192 KB |
Output is correct |
3 |
Correct |
106 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
2796 KB |
Output is correct |
2 |
Correct |
79 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
396 KB |
Output is correct |
2 |
Correct |
831 ms |
1140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1822 ms |
1820 KB |
Output is correct |
2 |
Correct |
1203 ms |
2168 KB |
Output is correct |
3 |
Execution timed out |
2061 ms |
2168 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
175 ms |
2304 KB |
Output is correct |
2 |
Correct |
987 ms |
2396 KB |
Output is correct |
3 |
Correct |
113 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
2812 KB |
Output is correct |
2 |
Correct |
78 ms |
2380 KB |
Output is correct |