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 "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int k=60;
ll x;
vector<ll> ps(k);
map<ll,ll> mp;
ll calc(ll t){
if(t<=0) return 0;
if(mp.count(t)) return mp[t];
int i=0;
ll y=1;
for(; y<t; i++,y<<=1);
i--;
return calc(1ll<<i)+calc(min(t,ps[i]/x+1)-(1ll<<i));
}
ll count_tastiness(ll x, vector<ll> a) {
::x=x;
a.resize(k);
ps[0]=a[0];
mp.clear();
for(int i=1; i<k; i++) ps[i]=(a[i]<<i)+ps[i-1];
mp[1]=1;
for(int i=1; i<=k; i++) mp[1ll<<i]=calc(1ll<<i);
return mp[1ll<<k];
}
# | 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... |