#include <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define vc vector
#define st first
#define nd second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)a.size()
#define pub push_back
#define pob pop_back
bool cont(ll mask, ll i) {
return (mask & (1ll << i)) != 0;
}
bool check(ll x, ll y, vc<ll> &a) {
ll n = sz(a);
ll sy = 0, sa = 0;
for (ll i = 0; i < n; i++) {
if (cont(y, i))
sy += x * (1ll << i);
sa += a[i] * (1ll << i);
if (sy > sa)
return false;
}
return true;
}
ll count_tastiness(ll x, vc<ll> a) {
ll n = sz(a);
ll ret = 0;
ll sum = 0;
for (ll i = 0; i < n; i++)
sum += a[i] * (1ll << i);
for (ll y = 0; x * y <= sum; y++) {
if (check(x, y, 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... |