Submission #239072

# Submission time Handle Problem Language Result Execution time Memory
239072 2020-06-14T10:02:40 Z NONAME Kotrljanje (COCI18_kotrljanje) C++14
42 / 140
2000 ms 2296 KB
#include <iostream>
#include <vector>
#include <queue>
#include <fstream>
#include <algorithm>
using namespace std;

using ll = long long;

const int N = 2e5 + 10;
const ll oo = 1e18;

ll c, d, b, m, cnt[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> c >> d >> b >> m;

    int p = 1;
    while (1) {
        ll v = c * p + d;

        int sm = 0;
        while (v > 0) {
            sm += v % b;
            v /= b;
        }

        cnt[sm]++;
        if (cnt[sm] == m) {
            for (int i = 0; i <= p; ++i) {
                ll v2 = c * i + d;

                int sm2 = 0;
                while (v2 > 0) {
                    sm2 += v2 % b;
                    v2 /= b;
                }

                if (sm2 == sm)
                    cout << i << ' ';
            }
            break;
        }

        p++;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 403 ms 636 KB Output is correct
2 Execution timed out 2084 ms 384 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2083 ms 480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2092 ms 632 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2078 ms 608 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2087 ms 480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 384 KB Output is correct
2 Correct 347 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 792 ms 1920 KB Output is correct
2 Correct 468 ms 2168 KB Output is correct
3 Correct 896 ms 2244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 430 ms 2296 KB Output is correct
2 Correct 408 ms 2176 KB Output is correct
3 Correct 561 ms 2296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2081 ms 520 KB Time limit exceeded
2 Halted 0 ms 0 KB -