Submission #364933

#TimeUsernameProblemLanguageResultExecution timeMemory
364933shjgkwoKotrljanje (COCI18_kotrljanje)C++11
140 / 140
881 ms3052 KiB
#include <iostream> using namespace std; long long count_sum[1000010]; long long sfirst[1000010]; long long ssecond[1000010]; long long c, d, b, m; long long get_sum(long long an) { long long sum = 0; while (an) { sum += an % b; an /= b; } return sum; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> c >> d >> b >> m; long long ans = -1; for (long long i = 1; i <= 1e9; i++) { long long sum = get_sum(c * i * (b - 1) + d); if (++count_sum[sum] == m) { ans = sum; break; } } for (long long i = 1; i <= 1e9; i++) { long long sum = get_sum(c * i * (b - 1) + d); if (sum == ans) { cout << i * (b - 1) << " "; if(--count_sum[ans] == 0) break; } } 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...