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;
ll A[61];
ll x;
ll f(ll n){
if(n <= 0)return 0;
if(n == 1)return 1;
if(dp.find(n) != dp.end())return dp[n];
ll a = __lg(n-1);
return dp[n] = f(1ll<<a) + f(min(n,1+A[a]/x)-(1ll<<a));
}
ll count_tastiness(ll k, vector<ll> a) {
x = k;
dp.clear();
while(a.size() <= 60)a.push_back(0);
A[0] = a[0];
for(int i = 1; i <= 60; ++i)A[i] = A[i-1] + (a[i]<<i);
return f(A[60]+1);
}
# | 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... |