#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll count_tastiness(ll x, vector<ll> a) {
int sm = 0;
for (int i = 0; i < (int)a.size(); i++) {
sm += (1 << i) * a[i];
}
while (!a.empty() && a.back() == 0) a.pop_back();
int ans = 0;
for (int i = 0; i <= sm / x; i++) {
bool ch = true;
vector <ll> b = a;
for (int j = 1; j <= x; j++) {
int cur = i;
for (int w = (int)b.size() - 1; w >= 0; w--) {
if (cur == 0) break;
int k = min(cur >> w, (int)b[w]);
cur -= k * (1 << w);
b[w] -= k;
}
if (cur != 0) {
ch = false;
break;
}
}
if (ch) ans++;
}
return ans;
}
# | 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... |