#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
int sum[1010000],c,d,b,m;
const int inf=1e12;
int mget(int x)
{
int res=0;
while(x)
{
res+=x%b;
x/=b;
}
return res;
}
signed main()
{
cin>>c>>d>>b>>m;
int now=inf;
for(int i=1;i<=1200000;i++,now+=(b-1))
{
int qwq=c*now+d;
int cnt=mget(qwq);
sum[cnt]++;
}
int mans=-1,pos=0;
for(int i=1;i<=1000000;i++)
{
if(sum[i]>mans)
{
mans=sum[i],pos=i;
}
}
now=inf;
int qaq=0;
for(int i=1;i<=1200000;i++,now+=(b-1))
{
int qwq=c*now+d;
int cnt=mget(qwq);
if(cnt==pos)
{
cout<<now<<" ";
++qaq;
if(qaq==m)
{
return 0;
}
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
376 KB |
Output is correct |
2 |
Correct |
102 ms |
3832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
3192 KB |
Output is correct |
2 |
Correct |
95 ms |
3192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
3320 KB |
Output is correct |
2 |
Correct |
94 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
3448 KB |
Output is correct |
2 |
Correct |
97 ms |
3452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
3576 KB |
Output is correct |
2 |
Correct |
245 ms |
3704 KB |
Output is correct |
3 |
Correct |
137 ms |
3832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
3832 KB |
Output is correct |
2 |
Correct |
101 ms |
3844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
656 ms |
632 KB |
Output is correct |
2 |
Correct |
1002 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1302 ms |
2612 KB |
Unexpected end of file - int64 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
228 ms |
3832 KB |
Output is correct |
2 |
Incorrect |
842 ms |
3832 KB |
Unexpected end of file - int64 expected |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
3704 KB |
Output is correct |
2 |
Correct |
110 ms |
3320 KB |
Output is correct |