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<unordered_map>
#include<iostream>
typedef long long ll;
using namespace std;
ll x;
ll coins[62];
ll s[62];
ll count(ll n){
if(n==1)
return 1;
if(n<1)
return 0;
int i=0;
ll pw2=2;
while(pw2<n){
pw2*=2;
i++;
}
pw2/=2;
return count(pw2)+count(min(n,s[i]/x+1)-pw2);
}
ll count_tastiness(ll X,vector<ll>a){
x=X;
for(int i=0;i<62;i++){
coins[i]=0;
}
for(int i=0;i<(int)a.size();i++)
coins[i]=a[i];
for(int i=0;i<62;i++){
ll num=(coins[i]-x)/2;
if(num>0){
coins[i+1]+=num;
coins[i]-=2*num;
}
s[i]=(1LL<<i)*coins[i];
if(i)
s[i]+=s[i-1];
}
return count(1LL<<62);
}
# | 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... |