#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7 + 37;
int a[maxn];
int cntdig(ll x, ll b){
int ret = 0;
while (x){
ret += (x % b);
x /= b;
}
return ret;
}
int main(){
ios_base::sync_with_stdio(false);
ll c, d, b, m;
cin >> c >> d >> b >> m;
ll t = 1;
while (t <= d)
t *= b;
t /= b;
t *= (b - 1);
int can;
for (int i = 1; ; i++){
ll x = c * t * i + d;
a[cntdig(x, b)] ++;
if (a[cntdig(x, b)] == m){
can = cntdig(x, b);
break;
}
}
for (int i = 1; m; i++){
ll x = c * t * i + d;
if (cntdig(x, b) == can){
cout << t * i << " ";
m --;
}
}
cout << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
95 ms |
3828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
2424 KB |
Output is correct |
2 |
Correct |
51 ms |
2424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
51 ms |
2552 KB |
Output is correct |
2 |
Correct |
59 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
2680 KB |
Output is correct |
2 |
Correct |
89 ms |
3448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
2680 KB |
Output is correct |
2 |
Correct |
200 ms |
3064 KB |
Output is correct |
3 |
Correct |
90 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
3832 KB |
Output is correct |
2 |
Correct |
60 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
376 KB |
Output is correct |
2 |
Correct |
848 ms |
1656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1834 ms |
2680 KB |
Output is correct |
2 |
Correct |
1147 ms |
2940 KB |
Output is correct |
3 |
Execution timed out |
2089 ms |
2808 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
118 ms |
2424 KB |
Output is correct |
2 |
Correct |
1043 ms |
3464 KB |
Output is correct |
3 |
Correct |
72 ms |
2948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
93 ms |
3704 KB |
Output is correct |
2 |
Correct |
57 ms |
2296 KB |
Output is correct |