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>
#define ll long long
#define pb push_back
#define SZ(x) (int)(x).size()
#define all(x) begin(x), end(x)
using namespace std;
const int n0 = 1e5;
ll count_tastiness(ll x, vector<ll> a) {
ll s = 0;
for (ll i = 0; i < SZ(a); i++)
s += (1ll << i) * a[i];
if (x > s) return 1;
ll res = 0;
if (s <= n0) {
for (ll i = 0; i <= s; i++) {
ll cur = 0;
for (ll j = 59; j >= 0; j--) {
if (i >> j & 1) cur += x;
if (j < SZ(a))
cur -= min(cur, a[j]);
cur *= 2;
}
res += (cur == 0);
}
} else if (x == 1) {
ll r = 0, res = 1, cur = 1;
for (ll j = 0; j < SZ(a); j++) {
if (!a[j]) continue;
ll t = (1ll << j) / cur;
if (t > r + 1) {
res *= (r + 1);
cur = (1ll << j);
r = 0;
}
t = (1ll << j) / cur;
if (t <= r + 1) r += a[j] * t;
}
res *= (r + 1);
}
return res;
}
# | 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... |