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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
ll count_tastiness(ll x, vector<ll> a)
{
while (a.size() < 60)
a.push_back(0);
ll s[61];
for (int i = 0; i <= 60; i++)
s[i] = 0;
for (int t = 1; t <= 60; t++)
{
s[60 - t] = s[60 - t + 1] + a[60 - t];
if (s[60 - t] >= x)
s[60 - t] -= x;
for (int i = 0; i < 60; i++)
{
s[i] *= 2;
if (s[i] >= x)
s[i] -= x;
}
}
cc_hash_table<ll, ll>M[61];
function<ll(ll, int)>get = [&](ll d, int i)->ll
{
if (i == 60)
return d / x + 1;
if (M[i].find(d) != M[i].end())
return M[i][d];
if (a[i] + d < x)
{
return M[i][d] = get((d + a[i]) / 2, i + 1);
}
else
{
return M[i][d] = get((d + a[i]) / 2, i + 1) + get((d + a[i] - x) / 2, i + 1);
}
};
return get(0, 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... |