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>
using namespace std;
#define ll long long
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
template<typename T>
int len(T &a){return a.size();}
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
vector<ll> cnt;
ll x;
map<pair<ll,ll>,ll> mp;
ll count(int i, ll j){
if(i == 63){
return j >= 0;
}
if(mp.count({i, j})) return mp[{i, j}];
ll res = 0;
res += count(i + 1, (j + cnt[i]) / 2);
if(j + cnt[i] >= x){
res += count(i + 1, (j - x + cnt[i]) / 2);
}
return res;
}
long long count_tastiness(long long X, vector<long long> A) {
cnt = A;
x = X;
while(len(cnt) < 63){
cnt.push_back(0);
}
for(int i = 0; i + 1 < 63; i ++){
if(cnt[i] >= 3){
if(cnt[i] % 2){
cnt[i + 1] += (cnt[i] - 1) / 2, cnt[i] = 1;
}else cnt[i + 1] += (cnt[i] - 2) / 2, cnt[i] = 2;
}
}
return count(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... |