#include <iostream>
#include "biscuits.h"
#include <vector>
using namespace std;
#define int long long
int x,k;
int a[61];
int po[61];
int ps[100];
int bef[100];
int auk[100];
int n1;
int fin(int z){
if(z<0){return 0;}
if(z==0){return 1;}
int sp;
for(int i=0; i<=60; i++){
if(po[i]<=z){sp=i;}
}
return bef[sp] + fin( min(z - po[sp], auk[sp]) );
}
int count_tastiness(int xa, vector<int> ah){
x = xa;
k = ah.size();
for(int i=0; i<=60; i++){a[i]=0; auk[i] = -1;}
for(int i=0; i<k; i++){
a[i] = ah[i];
}
po[0]=1;
for(int i=1; i<=60; i++){
po[i] = 2*po[i-1];
}
for(int i=0; i<60; i++){
if(a[i]>=x){
int xx = (a[i]-x)/2;
a[i] -= 2*xx;
a[i+1] += xx;
}
}
ps[0] = a[0];
for(int i=1; i<60; i++){
ps[i] = ps[i-1] + po[i] * a[i];
}
bef[0]=1;
for(int i=0; i<=59; i++){
bef[i+1] = bef[i];
if(a[i]>=x){
bef[i+1] += bef[i];
auk[i] = (ps[i-1])/x;
}
else {
n1 = ps[i] / x;
if(n1>=po[i]) {
auk[i] = n1 - po[i];
bef[i+1] += fin(auk[i]);
}
}
}
return bef[60];
}
# | 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... |