Submission #576297

# Submission time Handle Problem Language Result Execution time Memory
576297 2022-06-13T01:31:13 Z eecs Weird Numeral System (CCO21_day1problem2) C++17
0 / 25
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int K, q, d;
    cin >> K >> q >> d >> *new int;
    vector<int> a(d);
    for (int &x : a) cin >> x;
    while (q--) {
        ll n;
        cin >> n;
        array<unordered_set<ll>, 80> f;
        f[0].insert(n);
        bool flag = 0;
        for (int i = 1; i < 80; i++) {
            for (ll x : f[i - 1]) {
                for (int y : a) if (!((x - y) % K)) {
                    f[i].insert((x - y) / K);
                }
            }
            if (f[i].count(0)) {
                for (ll x = 0; i; i--) {
                    for (int y : a) if (f[i - 1].count(x * K + y)) {
                        cout << y << " ";
                        x = x * K + y; break;
                    }
                }
                cout << "\n", flag = 1; break;
            }
        }
        if (!flag) cout << "IMPOSSIBLE\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected integer, but "IMPOSSIBLE" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected integer, but "IMPOSSIBLE" found
2 Halted 0 ms 0 KB -