# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
311943 | colazcy | Kotrljanje (COCI18_kotrljanje) | C++17 | 2086 ms | 3720 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 100000;
ll c,d,b,m;
inline ll f(ll x){return c * x + d;}
inline int cnt(ll x){
int res = 0;
while(x){
res += x % b;
x /= b;
}
return res;
}
vector<int> vec[maxn];
int p = 0;
int main(){
// freopen("kotrljanje.in","r",stdin);
// freopen("kotrljanje.out","w",stdout);
scanf("%lld %lld %lld %lld",&c,&d,&b,&m);
for(int i = 0;i < maxn;i++){
int x = cnt(f(i));
if(x < maxn)vec[x].push_back(i);
}
for(int i = 0;i < maxn;i++)
if(m <= vec[i].size()){
for(int j = 0;j < m;j++)printf("%d ",vec[i][j]);
return 0;
}
for(int i = 0;i < maxn;i++)
if(vec[i].size() >= 2){
p = i;
break;
}
for(int i = p + 1;i < maxn;i++)
if(vec[i].size() >= 2){
int x = vec[i][1] - vec[i][0],y = vec[p][1] - vec[p][0];
if(x < y || (x == y && vec[i].size() > vec[p].size()))p = i;
}
int delta = vec[p][1] - vec[p][0];
for(int i = 0;i < vec[p].size();i++)printf("%d ",vec[p][i]);
m -= vec[p].size();
for(ll now = vec[p].size() + delta;;now += delta){
if(cnt(f(now)) == p){
printf("%lld ",now);
m--;
}
if(!m)break;
}
fclose(stdin);
fclose(stdout);
return 0;
}
Compilation message (stderr)
# | 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... |