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>
#include "biscuits.h"
using namespace std;
typedef long long ll;
ll arr[105];
ll val[105];
ll p2[105];
ll k;
unordered_map<ll, ll> DP[102];
ll solve(int x, ll y){
if(x==0) return y+1;
if(DP[x][y]) return DP[x][y];
ll ret = 0;
ret += solve(x-1, min({val[x-1], y, p2[x]-1}));
if(y >= p2[x]) ret += solve(x-1, min({val[x-1], y-p2[x], p2[x]-1}));
return DP[x][y] = ret;
}
ll count_tastiness(ll _x, vector<ll> a) {
k = _x;
a.resize(60);
for(int i=0; i<60; i++){
arr[i] = a[i];
DP[i].clear();
p2[i] = 1LL<<i;
}
for(int i=0; i<60; i++){
val[i] = 0;
for(int j=0; j<=i; j++){
val[i] += arr[j] << j;
}
val[i] /= k;
}
return solve(59, val[59]);
}
# | 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... |