Submission #239475

#TimeUsernameProblemLanguageResultExecution timeMemory
239475VEGAnnKotrljanje (COCI18_kotrljanje)C++14
140 / 140
879 ms2936 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MX = 100100; int cnt[MX]; ll C, D, B, M; int f(ll x){ x = C * x + D; int res = 0; while (x > 0){ res += x % B; x /= B; } return res; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> C >> D >> B >> M; for (ll i = 1; ; i += B - 1){ int cur = f(i); cnt[cur]++; if (cnt[cur] == M){ for (ll j = 1; j < i; j += B - 1) if (f(j) == cur) cout << j << " "; cout << i; return 0; } } return 0; }
#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...