# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411676 | Dormi | Weird Numeral System (CCO21_day1problem2) | C++14 | 1106 ms | 4920 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T>
int sz(const T &a){return int(a.size());}
ll k;
unordered_map<ll,ll> memo;
vector<ll> arr;
bool solve(ll a){
if(memo.count(a))return memo[a]!=LLONG_MAX;
memo[a]=LLONG_MAX;
for(auto x:arr){
if((a-x)%k==0){
if(a-x==0||solve((a-x)/k)){
memo[a]=x;
return true;
}
}
}
return false;
}
int main(){
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int q,d,m;
cin>>k>>q>>d>>m;
arr.resize(d);
for(int i=0;i<d;i++)cin>>arr[i];
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |