이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
br.resize(k); toadd.resize(k);
for(int i=0;i<k;i++){
br[i]=A[i];
sum+=br[i]*(1LL<<i);
}
return brute(k-1,sum);
}
/*
int main(){
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... |