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;
typedef long long ll;
const int maxn = 5000 + 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 - 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 |
---|
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... |