#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#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 F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 101001
#define M ll(1e9 + 7)
#define inf 1e9 + 1e9
using namespace std;
//using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
typedef short int si;
typedef array <int, 3> a3;
//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
unordered_map <ll, vector <ll> > koler;
int main()
{
//freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout);
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll c, b, d, m;
cin >> c >> d >> b >> m;
ll dob = 1;
if (b >= 50) dob = b - 1;
for (ll i = 1; ; i += dob)
{
ll val = i * c + d;
ll sum = 0;
while (val > 0)
{
sum += val % b;
val /= b;
}
koler[sum].pb(i);
if (sz(koler[sum]) == m)
{
for (auto it : koler[sum]) cout << it << " ";
exit(0);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
512 KB |
Output is correct |
2 |
Correct |
56 ms |
6996 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
5808 KB |
Output is correct |
2 |
Correct |
46 ms |
5104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
47 ms |
5848 KB |
Output is correct |
2 |
Correct |
52 ms |
5948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
43 ms |
5468 KB |
Output is correct |
2 |
Correct |
48 ms |
5452 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
54 ms |
5852 KB |
Output is correct |
2 |
Correct |
202 ms |
20068 KB |
Output is correct |
3 |
Correct |
51 ms |
6500 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
6360 KB |
Output is correct |
2 |
Correct |
51 ms |
6616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
1152 KB |
Output is correct |
2 |
Correct |
193 ms |
6860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
431 ms |
14744 KB |
Output is correct |
2 |
Correct |
279 ms |
16556 KB |
Output is correct |
3 |
Correct |
494 ms |
16408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
351 ms |
39796 KB |
Output is correct |
2 |
Correct |
239 ms |
12348 KB |
Output is correct |
3 |
Correct |
51 ms |
6116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
6376 KB |
Output is correct |
2 |
Correct |
49 ms |
5580 KB |
Output is correct |