# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1125085 | Pannda | Weird Numeral System (CCO21_day1problem2) | C++20 | 2614 ms | 525728 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int K, Q, D, M;
cin >> K >> Q >> D >> M;
vector<int> digits(D);
for (int i = 0; i < D; i++) {
cin >> digits[i];
}
while (Q--) {
long long N;
cin >> N;
map<long long, int> par;
for (int d : digits) {
par[d] = d;
}
const int IMPOSSIBLE = 6785;
auto backtrack = [&](auto self, long long n) -> bool {
if (par.count(n)) return par[n] != IMPOSSIBLE;
for (int d : digits) {
if ((n - d) % K == 0 && self(self, (n - d) / K)) {
par[n] = d;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |