이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
long long x,sum;
int k;
vector<long long> br,toadd;
int brute(int bit,long long total,vector<long long> br){
if(bit==-1)return 1;
long long curr=br[bit];
total-=curr*(1LL<<bit); br[bit]=0;
int res=brute(bit-1,total,br);
total+=curr*(1LL<<bit); br[bit]=curr;
curr=x;
if(total>=x*(1LL<<bit)){
total-=x*(1LL<<bit);
int pos=bit;
for(int i=bit;i>=0;i--){
if(br[i]>=curr){
br[i]-=curr;
curr=0; pos=i; break;
}else{
curr-=br[i];
br[i]=0; curr*=2;
}
}
total-=br[bit]*(1LL<<bit); br[bit]=0;
res+=brute(bit-1,total,br);
}
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,br);
}
/*
int main(){
cout<<count_tastiness(2, {2, 1, 2})<<"\n";
cout<<count_tastiness(2, {2, 1, 2})<<"\n";
}
*/
컴파일 시 표준 에러 (stderr) 메시지
biscuits.cpp: In function 'int brute(int, long long int, std::vector<long long int>)':
biscuits.cpp:20:13: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
20 | int pos=bit;
| ^~~
# | 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... |