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 <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
#define int long long
#define SZ(x) ((int)(x).size())
#define all(x) begin(x), end(x)
bool chk(int v, int x, vector<int> cnt) {
for(int i = 0; i < x; i++) {
int val = v;
for(int j = SZ(cnt) - 1; j >= 0; j--) {
int need = min(cnt[j], val / (1LL << j));
cnt[j] -= need; val -= (1ll << j) * need;
}
if(val) return false;
}
return true;
}
int count_tastiness(int x, vector<int> a) {
int k = a.size();
int sum = 0;
for(int i = 0; i < k; i++) {
sum = sum + (1LL << i) * a[i];
}
int ret = 1;
if(x == 1) {
for(int i = k - 1; i > 0; i--) {
if(a[i - 1] >= 2) {
a[i - 1] = a[i - 1] + a[i] * 2LL;
a[i] = 0;
}
}
for(int i = 0; i < k; i++) {
ret = ret * (a[i] + 1LL);
}
}
else {
for(int i = 1; i * x <= sum; i++) {
if(chk(i, x, a)) ret++;
}
}
return ret;
}
# | 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... |