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>
#define fi first
#define se second
using namespace std;
const int K=60;
vector<long long> ans(K);
vector<long long> s(K);
long long _x;
inline long long cc(int i)
{
long long xd=(s[i]/_x);
if(xd>=(1LL<<(i+1)))
return (1LL<<(i+1))-1;
return xd;
}
long long f(int i,long long l)
{
if(i==0)
{
if(l>0 && cc(i)>0)
return 2;
return 1;
}
if((l&(1LL<<i)) && (cc(i)&(1LL<<i)))
return ans[i-1]+f(i-1,min(l,cc(i))^(1LL<<i));
return f(i-1,min(l,cc(i)));
}
long long count_tastiness(long long x,vector<long long> a)
{
_x=x;
while(a.size()<K)
a.push_back(0);
s[0]=a[0];
for(int i=1;i<K;i++)
s[i]=(s[i-1]+(1LL<<i)*a[i]);
for(int i=0;i<K;i++)
ans[i]=f(i,(1LL<<(i+1))-1);
//cerr<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<"\n";
return ans[K-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... |