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 <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
typedef long long llong;
const int MAXN = 64;
const int INF = 1e9;
int n;
llong x;
llong a[MAXN];
llong rec(int pos, llong prenos)
{
if (pos == n)
{
return 1;
}
llong ans = 0;
llong curr = a[pos] + prenos;
if (curr >= x) ans += rec(pos + 1, (curr - x) / 2);
ans += rec(pos + 1, curr / 2);
return ans;
}
bool check(int pos, int y, llong prenos)
{
if (pos == n)
{
return 1;
}
llong ans = 0;
llong curr = a[pos] + prenos;
if (y & (1 << pos))
{
if (curr < x) return 0;
return check(pos + 1, y, (curr - x) / 2);
}
return check(pos + 1, y, curr / 2);
}
llong count_tastiness(llong X, std::vector <llong> A)
{
n = A.size();
x = X;
llong sum = 0;
for (int i = 0 ; i < n ; ++i)
{
a[i] = A[i];
sum += a[i] * (1LL << a[i]);
}
for (int y = 0 ; y <= sum ; ++y)
{
check(0, 0, y);
}
return rec(0, 0);
}
Compilation message (stderr)
biscuits.cpp: In function 'bool check(int, int, llong)':
biscuits.cpp:37:11: warning: unused variable 'ans' [-Wunused-variable]
37 | llong ans = 0;
| ^~~
# | 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... |