제출 #332421

#제출 시각아이디문제언어결과실행 시간메모리
332421katearima비스킷 담기 (IOI20_biscuits)C++14
0 / 100
192 ms384 KiB
#include "biscuits.h" #include <bits/stdc++.h> #define ll long long using namespace std; const int k=64; int i; int nearest(ll u){ vector<int> v; while(u>0){ v.push_back(u%2); u/=2; } for(int i=v.size()-1; i>=0; i--){ if(v[i]==1) return i; } return -1; } long long count_tastiness(long long x, vector<long long> a) { vector<ll> s(k+1),ans(k+1); int n=a.size(); for(i=0; i<k-1; i++){ if(i<n) s[i]+=a[i]*pow(2,i); s[i+1]+=s[i]; } ans[0]=1; for(i=1; i<k; i++){ ans[i]+=ans[i-1]; int j=i-1; ll c=1; ll p; while(c>0){ p=pow(2,j); c=min(s[j],2*p-1)-p; if(c==0){ ans[i]++; break; } if(c<0) break; j=nearest(c); ans[i]+=ans[j]; } } return ans[k-1]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...