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>
using namespace std;
long long x,sum,curr;
int k,pos;
vector<long long> br,toadd;
int brute(int bit,long long total){
if(bit==-1)return 1;
int res=brute(bit-1,total-br[bit]*(1LL<<bit));
curr=x; pos=bit;
if(total>=x*(1LL<<bit)){
total-=x*(1LL<<bit);
for(int i=bit;i>=0;i--){
if(br[i]>=curr){
br[i]-=curr; toadd[i]=curr;
curr=0; pos=i; break;
}else{
curr-=br[i]; toadd[i]=br[i];
br[i]=0; curr*=2;
}
}
res+=brute(bit-1,total-br[bit]*(1LL<<bit));
for(int i=bit;i>=pos;i--){
br[i]+=toadd[i]; toadd[i]=0;
}
}
return res;
}
long long count_tastiness(long long X,vector<long long> A){
k=int(A.size()); x=X; sum=0;
br.resize(62); toadd.resize(62);
for(int i=0;i<k;i++){
br[i]=A[i];
sum+=br[i]*(1LL<<i);
}
return brute(61,sum);
}
/*
int main(){
cout<<count_tastiness(2, {2, 1, 2})<<"\n";
cout<<count_tastiness(2, {2, 1, 2})<<"\n";
}
*/
# | 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... |