# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
652629 | BidoTeima | Kotrljanje (COCI18_kotrljanje) | C++17 | 106 ms | 2580 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.
/*
ID: BidoTeima
LANG: C++11
TASK: Izbori
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void moo(string filename);
void ACPLS(string str = "")
{
if(str=="NOF")return;
if(str.size())
moo(str);
else{
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
}
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void moo(string fileName){
freopen((fileName+".in").c_str(),"r",stdin);
freopen((fileName+".out").c_str(),"w",stdout);
}
#define tc \
int tttttt/*,subtask*/; \
cin >> tttttt/* >> subtask*/; \
while (tttttt--)/*end
*/
ll sodB(ll x, ll B){
ll ret = 0;
while(x){
ret+=x%B;
x/=B;
}
return ret;
}
int main()
{
//ACPLS("");
ll C,D,B,M;
cin>>C>>D>>B>>M;
ll start = -1, diff = 0;
for(int s = 1; s <= 1e4; s++){
for(int d = 1; d <= 5000; d++){
ll sumdigits = sodB(C*s+D,B);
if(sumdigits == sodB(C*(s+d)+D,B)){
ll lstN = s+d*(M-1);
if(sumdigits==sodB(C*lstN+D,B)){
start = s, diff = d;
}
break;
}
}
if(start != -1)break;
}
while(M--){
cout<<start<<' ';
start+=diff;
}
}
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... |