#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;
int t = cntdig(x, b);
a[t] ++;
if (a[t] == m){
can = t;
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 |
75 ms |
3960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2424 KB |
Output is correct |
2 |
Correct |
43 ms |
2424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
2424 KB |
Output is correct |
2 |
Correct |
44 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
2680 KB |
Output is correct |
2 |
Correct |
74 ms |
3464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2680 KB |
Output is correct |
2 |
Correct |
144 ms |
3064 KB |
Output is correct |
3 |
Correct |
77 ms |
3412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
3704 KB |
Output is correct |
2 |
Correct |
48 ms |
2936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
376 KB |
Output is correct |
2 |
Correct |
571 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1236 ms |
2772 KB |
Output is correct |
2 |
Correct |
775 ms |
3192 KB |
Output is correct |
3 |
Correct |
1466 ms |
3104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
89 ms |
2296 KB |
Output is correct |
2 |
Correct |
696 ms |
3320 KB |
Output is correct |
3 |
Correct |
58 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
3804 KB |
Output is correct |
2 |
Correct |
48 ms |
2296 KB |
Output is correct |