Submission #239474

#TimeUsernameProblemLanguageResultExecution timeMemory
239474VEGAnnKotrljanje (COCI18_kotrljanje)C++14
126 / 140
885 ms2808 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 (int i = 1; ; i += B - 1){ int cur = f(i); cnt[cur]++; if (cnt[cur] == M){ for (int 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...