#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define i2 array<int,2>
#define PB push_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
using namespace std;
typedef long long ll;
const int N = 20100;
const ll OO = 1e18;
const int oo = 2e9;
const int md = int(1e9) + 7;
int cnt[N];
ll C, D, B, M;
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 (ll i = 1; ; i++){
ll cur = i * C + D;
ll sum = 0;
while (cur > 0){
sum += cur % B;
cur /= B;
}
cnt[sum]++;
if (cnt[sum] == M){
for (ll j = 1; j < i; j++) {
cur = j * C + D;
ll nw = 0;
while (cur > 0){
nw += cur % B;
cur /= B;
}
if (sum == nw)
cout << j << " ";
}
cout << i;
return 0;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
401 ms |
632 KB |
Output is correct |
2 |
Execution timed out |
2087 ms |
504 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2085 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2082 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2068 ms |
512 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2088 ms |
504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2083 ms |
504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
33 ms |
256 KB |
Output is correct |
2 |
Correct |
349 ms |
1144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
785 ms |
1788 KB |
Output is correct |
2 |
Correct |
466 ms |
2168 KB |
Output is correct |
3 |
Correct |
889 ms |
2296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
427 ms |
2428 KB |
Output is correct |
2 |
Correct |
410 ms |
2180 KB |
Output is correct |
3 |
Correct |
565 ms |
2424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2091 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |