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 <iostream>
#include <vector>
#include <map>
using namespace std;
int mp[30000];
long long c, d, b, m, p, i, n, suma, sol;
int main () {
cin>>c>>d>>b>>m;
p = 1;
while (p <= d)
p*=b;
for (i=1;;i++) {
n = 1LL*c*i+d;
suma = 0;
while (n) {
suma += n%b;
n/=b;
}
mp[suma] ++;
if (mp[suma] == m) {
sol = suma;
break;
}
///}
}
for (i=1;m;i++) {
n = 1LL*c*i+d;
suma = 0;
while (n) {
suma += n%b;
n/=b;
}
if (suma == sol) {
cout<<i<<" ";
m--;
}
///}
}
}
# | 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... |