#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX = 100100;
int cnt[MX];
ll C, D, B, M;
int f(ll x){
x = C * x + D;
int res = 0;
while (x > 0){
res += x % B;
x /= B;
}
return res;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> C >> D >> B >> M;
for (int i = 1; ; i += B - 1){
int cur = f(i);
cnt[cur]++;
if (cnt[cur] == M){
for (int j = 1; j < i; j += B - 1)
if (f(j) == cur)
cout << j << " ";
cout << i;
return 0;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Incorrect |
19 ms |
384 KB |
Expected unsigned integer, but "-898486655" found |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
2424 KB |
Output is correct |
2 |
Correct |
40 ms |
2424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
2552 KB |
Output is correct |
2 |
Correct |
49 ms |
2556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
2680 KB |
Output is correct |
2 |
Correct |
42 ms |
2680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
2680 KB |
Output is correct |
2 |
Correct |
101 ms |
2168 KB |
Output is correct |
3 |
Correct |
58 ms |
2680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2808 KB |
Output is correct |
2 |
Correct |
53 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
512 KB |
Output is correct |
2 |
Correct |
348 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
777 ms |
1804 KB |
Output is correct |
2 |
Correct |
466 ms |
2168 KB |
Output is correct |
3 |
Correct |
885 ms |
2040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
78 ms |
2296 KB |
Output is correct |
2 |
Correct |
439 ms |
2424 KB |
Output is correct |
3 |
Correct |
53 ms |
2808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
2808 KB |
Output is correct |
2 |
Correct |
52 ms |
2296 KB |
Output is correct |