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;
using ll = long long;
map<ll,ll>mp;
ll S[66];
int K;
ll x;
ll g(ll n) {
if (n <= 1) return n == 1 ? 1 : 0;
if (mp.count(n)) return mp[n];
int i = 60;
while ((1ll << i) >= n) --i;
mp[n] = g(1ll << i) + g(min(n, 1 + S[i] / x) - (1ll << i));
return mp[n];
}
ll count_tastiness(ll x_, vector<ll> a) {
mp.clear();
K = 62;
while ((int)a.size() < K) a.push_back(0);
x = x_;
for (int i = 0 ; i < K ; ++ i) S[i] = 0;
for (int i = 0 ; i < K ; ++ i) {
for (int j = 0 ; j <= i ; ++ j) {
S[i] += (1ll << j) * a[j];
}
}
return g(S[K-1]+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... |