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;
 
typedef long long ll;
map<ll, ll> dp;
vector<ll> s;
ll x;
ll g(ll n) {
	if(n<=0) return 0;
	if(n==1) return 1;
	if(dp.count(n)) return dp[n];
	ll b=0, p=1;
	while(p<n) b++,p*=2;
	p/=2;
	b--;
	return dp[n]=g(p)+g(min(n,1+s[b]/x)-p);
}
 
long long count_tastiness(long long X, std::vector<long long> a) {
	x=X;
	while(a.size()<60) a.push_back(0);
 	
 	s.clear();
 	dp.clear();
 	ll sum=0;
 	for(int i=0;i<60;i++) {
 		sum+=(1LL<<i)*a[i];
 		s.push_back(sum);
 	}
 	return g(1LL<<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... |