#include <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
typedef long long ll;
typedef __int128 xl;
typedef pair<ll, ll> pll;
#define vc vector
#define st first
#define nd second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)a.size()
#define pub push_back
#define pob pop_back
bool cont(xl mask, xl i) {
return (mask & (xl(1) << i)) != 0;
}
ll count_tastiness(ll _x, vc<ll> _a) {
xl x = _x;
vc<xl> a(all(_a));
xl n = sz(a);
vc<xl> dp(140, 1);
xl sa = 0;
for (xl i = 0; ; i++) {
if (i < n)
sa += a[i] * (xl(1) << i);
xl b = min(sa / x, (xl(1) << (i + 1)) - 1);
for (xl j = 0; j <= i; j++)
if (cont(b, j))
dp[i + 1] += dp[j];
if (dp[i + 1] == dp[i] and i >= n)
return dp[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... |