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 "biscuits.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(),v.end()
template<typename T>
void dbg(const T& t){
cout<<t<<endl;
}
template<typename T,typename... Args>
void dbg(const T& t,const Args&... args){
cout<<t<<" , ";
dbg(args...);
}
#define dbg(...) cout<<"("<<#__VA_ARGS__<<") : ";dbg(__VA_ARGS__);
int count_tastiness(int x, vector<int> a) {
int n=a.size();
int s=0;
for(int i=0;i<n;i++){
s+=a[i]*(1LL<<i);
}
int ans=s+1;
vector<int> b(61);
for(int i=0;i<n;i++) b[i]=a[i];
// dbg(s)
for(int i=0;i<61;i++){
if(s/(1LL<<i)==0) break;
if(b[i]==0){
int n=s+1;
int k=i;
long long res = (n >> (k + 1)) << k;
if((n>>k)&1) res+=n&((1LL<<k)-1);
ans-=res;
// dbg(i,res)
}
}
return ans;
}
int cnt(int x, vector<int> a) {
int n=a.size();
int ans = 0;
int s=0;
for(int i=0;i<n;i++){
s+=a[i]*(1LL<<i);
}
auto check = [&](int mid,int y){
vector<int> b(61);
int m=61;
for(int i=0;i<n;i++) b[i]=a[i];
for(int j=0;j<m;j++){
if((1LL<<j)&y){
if(b[j]<mid) return false;
b[j]-=mid;
}
if(j+1<m) b[j+1]+=(b[j]>>1);
}
return true;
};
for(int y=0;y<=s;y++){
if(check(x,y)){
ans++;
dbg(y)
}
}
return ans;
}
# | 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... |