이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |