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>
#define ll long long
using namespace std;
ll koll[65],treba[65],tmp[65],K,X;
string A;
string ubin(int x){
string ret="";
while(x){
if(x%2==1)
ret.push_back(1);
else
ret.push_back(0);
x/=2;
}
//reverse(ret.begin(),ret.end());
return ret;
}
bool mozeli(int koji){
A=ubin(koji);
int N=A.size();
for(int i=0;i<A.size();i++)
treba[i+1]=A[i]*X;
for(int i=1;i<=N;i++)
tmp[i]=koll[i];
for(int i=1;i<=N;i++){
if(treba[i]>tmp[i])
return false;
tmp[i]-=treba[i];
tmp[i+1]+=tmp[i]/2;
}
return true;
}
ll subtsk1(ll x,vector<ll> a){
memset(koll,0,sizeof(koll));
memset(treba,0,sizeof(treba));
memset(tmp,0,sizeof(tmp));
K=a.size();
X=x;
for(int i=1;i<=K;i++)
koll[i]=a[i-1];
ll res=0;
for(int i=0;i<=100000;i++){
res+=mozeli(i);
}
return res;
}
#include "biscuits.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MaxK=60;
ll res,br,kol[MaxK*4],stepen[MaxK*4],del;
ll count_tastiness(ll x,vector<ll> A){
if(x!=1)
return subtsk1(x,A);
stepen[0]=1;
for(int i=1;i<=MaxK;i++)
stepen[i]=stepen[i-1]*2;
for(int i=MaxK+1;i<MaxK*4;i++)
stepen[i]=1;
br=x;
K=A.size();
for(int i=0;i<K;i++)
kol[i]=A[i];
for(int i=K;i<4*MaxK;i++)
kol[i]=0;
res=1;
ll br=0,maks=0;
del=1;
for(int i=0;i<4*MaxK;i++){
if(br<1){
res*=(maks+1);
// cout<<i<<" "<<maks+1<<endl;
br=0;
maks=0;
del=stepen[i];
}
br+=kol[i];
maks+=kol[i]*stepen[i]/del;
br/=2;
}
return res;
}
Compilation message (stderr)
biscuits.cpp: In function 'bool mozeli(int)':
biscuits.cpp:22:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(int i=0;i<A.size();i++)
| ~^~~~~~~~~
# | 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... |