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