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>
using namespace std;
int check_y(long long x, std::vector<long long> a, int y)
{
int i, k = a.size();
for (i = 0; i < k; i++)
if ((1 << i) > y)
break;
i--;
long long t = y * x;
while (i>=0) {
long long p = t / (1 << i);
t -= min(a[i], p)*(1 << i);
if (t == 0)
return 1;
i--;
}
return t == 0;
}
long long count_tastiness(long long x, std::vector<long long> a)
{
int res = 1;
int k = a.size();
long long total = 0;
for (int i = 0; i < k; i++)
total += (1 << i)*a[i];
if (total < x)
return 1;
for (int y = 1; y <= total; y++)
res += check_y(x, a, y);
return res;
}
# | 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... |