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;
using ll = long long;
using i128 = __int128_t;
ll count_tastiness(ll x, vector<ll> a) {
const i128 B = 60;
vector<i128> A(B, 0);
for(int i = 0; i < (int)a.size(); i++) A[i] = a[i];
i128 X = x;
vector<i128> psum(B+1, 0);
for(int i = 0; i < B; i++){
psum[i+1] = psum[i] + (A[i] << i);
}
vector<i128> cnt(B+1, 0);
cnt[B] = 1;
for(int i = B; i > 0; i--){
i128 cmin = psum[i];
i128 cmax = psum[i];
for(int j = i-1; j >= 0; j--){
if(cmin >= (X << j)) cmin -= (X << j);
if(cmax >= psum[j]){
if(cmax >= cmin){
cnt[j] += cnt[i] * (1 + (cmax - max(cmin, psum[j])) / (X << j));
}
cmax -= (1 + (cmax - psum[j]) / (X << j)) * (X << j);
}
}
}
return (ll)cnt[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... |