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;
typedef long long ll;
long long count_tastiness(long long x, std::vector<long long> a) {
if(x == 1) {
for(int i = (int)a.size()-1; i > 0; i--) if(a[i-1]) a[i-1] += 2*a[i], a[i] = 0;
ll res = 1;
for(ll x : a) res *= (x+1);
return res;
}
ll ans = 0;
for(int v = 0; v <= 100000; v++) {
vector<ll> b = a;
int idx = (int)a.size()-1;
bool ok = true;
for(int j = 20; j >= 0; j--) {
if((v>>j)&1) {
while(idx > j) idx--;
bool flag = false;
ll cnt = x;
while(cnt) {
while(idx >= 0 && b[idx] < (1<<(j-idx))) idx--;
if(idx == -1) {
flag = true;
break;
}
b[idx] -= (1<<(j-idx)); cnt--;
}
if(flag) {
ok = false;
break;
}
}
}
if(ok) 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... |