#include "biscuits.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2")
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
long long count_tastiness(ll k, std::vector<long long> a) {
ll sum = 0;
while(!a.empty() && a.back() == 0) a.pop_back();
int n = (int)a.size();
for(int i = 0; i < n; i++) sum += a[i] * (1ll << i);
vector<ll> ori = a;
auto f = [&](ll now){
a = ori;
for(int times = 0; times < k; times++){
ll x = now;
for(int i = n - 1; i >= 0; i--){
if(x == 0) break;
ll res = min(a[i], x / (1ll << i));
x -= res * (1ll << i);
a[i] -= res;
}
if(x != 0) return 0;
}
return 1;
};
ll ans = 0;
for(ll i = 0; i * k <= sum; i++){
ans += f(i);
//if(f(i) == 1) cout << i << endl;
}
return ans;
}
// g++ -std=c++17 -Wall -Wextra -Wshadow -fsanitize=undefined -fsanitize=address -o run -g biscuits.cpp grader.cpp
# | 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... |