Submission #200161

#TimeUsernameProblemLanguageResultExecution timeMemory
200161SaboonKotrljanje (COCI18_kotrljanje)C++14
140 / 140
1466 ms3960 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e7 + 37; int a[maxn]; int cntdig(ll x, ll b){ int ret = 0; while (x){ ret += (x % b); x /= b; } return ret; } int main(){ ios_base::sync_with_stdio(false); ll c, d, b, m; cin >> c >> d >> b >> m; ll t = 1; while (t <= d) t *= b; t /= b; t *= (b - 1); int can; for (int i = 1; ; i++){ ll x = c * t * i + d; int t = cntdig(x, b); a[t] ++; if (a[t] == m){ can = t; break; } } for (int i = 1; m; i++){ ll x = c * t * i + d; if (cntdig(x, b) == can){ cout << t * i << " "; m --; } } cout << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...