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<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<deque>
#include<string>
#include<unordered_map>
#include<bitset>
#include<random>
#include<chrono>
#include<cstdarg>
//Eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
using namespace std;
const int MAXN = 61;
typedef long long ul;
map<ul, ul> dp;
ul X;
vector<ul> psa;
ul f(ul i) {
if (i == 0) return 1;
if (i < 0) return 0;
if (dp.find(i) == dp.end()) {
ul mx = 0;
for (mx = MAXN; mx >= 0; mx--) if (i >> mx & 1) break;
dp[i] = f((1LL << mx) - 1) + f(min(i, psa[mx] / X) - (1LL << mx));
}
return dp[i];
}
ul count_tastiness(ul x, vector<ul> a) {
X = x; a.resize(MAXN);
dp.clear();
psa = vector<ul>(MAXN);
psa[0] = a[0];
for (int i = 1; i < MAXN; i++) psa[i] = psa[i - 1] + (a[i] << i);
return f((1LL << 60)-1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |