/*#include <vector>
long long count_tastiness(long long x, std::vector<long long> a);
#include "biscuits.h"
#include <cassert>
#include <cstdio>
using namespace std;
int main() {
int q;
assert(scanf("%d", &q) == 1);
vector<int> k(q);
vector<long long> x(q);
vector<vector<long long>> a(q);
vector<long long> results(q);
for (int t = 0; t < q; t++) {
assert(scanf("%d%lld", &k[t], &x[t]) == 2);
a[t] = vector<long long>(k[t]);
for (int i = 0; i < k[t]; i++) {
assert(scanf("%lld", &a[t][i]) == 1);
}
}
fclose(stdin);
for (int t = 0; t < q; t++) {
results[t] = count_tastiness(x[t], a[t]);
}
for (int t = 0; t < q; t++) {
printf("%lld\n", results[t]);
}
fclose(stdout);
return 0;
}*/
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<unordered_map<ll,ll>> dp;
vector<ll> a2,li;
ll x2;
ll solve(ll idx, ll n){
if(n<0) return 0;
if(idx<0) return 1ll;
if(dp[idx].find(n)!=dp[idx].end()) return dp[idx][n];
return dp[idx][n]=solve(idx-1,min(min(n,(1ll<<idx)-1),li[idx]))+solve(idx-1,min(min(n-(1ll<<idx),(1ll<<idx)-1),li[idx]-(1ll<<idx)));
}
ll count_tastiness(ll x, vector<ll> a) {
dp.clear();a2.clear();li.clear();
dp.resize(61);a2.resize(61);
x2=x;
ll s=0;
for(int i=0;i<61;i++){
if(i<a.size()) s+=a[i]<<i;
li.push_back(s/x);
}
solve(60,(1ll<<61ll)-1ll);
return dp[60][(1ll<<61ll)-1ll];
}
| # | 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... |