This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
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... |