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 <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
typedef long long ll;
ll x, s[61];
map<ll, ll> mp[61];
ll Calc(int bit, ll n){
if (n < 1)
return 0;
if (bit == -1)
return 1;
n = min(n, min((ll) 2 << bit, s[bit] / x + 1));
if (mp[bit].count(n))
return mp[bit][n];
ll res = 0;
res = Calc(bit - 1, n - ((ll) 1 << bit)) + Calc(bit - 1, n);
mp[bit][n] = res;
return res;
}
long long count_tastiness(long long _x, std::vector<long long> a) {
x = _x;
for(int i = 0; i <= 60; i++){
s[i] = 0;
if (i < (int) a.size())
s[i] = a[i] * ((ll) 1 << i);
if (i)
s[i] += s[i - 1];
mp[i].clear();
}
return Calc(60, (ll) 1 << 60);
}
# | 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... |