이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
long long s[60], x;
unordered_map<long long, long long> memo;
long long dp(long long n) {
if(n == 1) return 1;
if(n <= 0) return 0;
if(memo.count(n)) return memo[n];
int bt = 63-__builtin_clzll(n-1);
long long pw = 1LL<<bt;
return memo[n] = dp(pw) + dp(min(n, 1+s[bt]/x)-pw);
}
long long count_tastiness(long long X, std::vector<long long> a) {
x = X;
while(a.size() < 60) a.push_back(0);
s[0] = a[0];
for(int i = 1; i < 60; i++) s[i] = s[i-1] + a[i]*(1LL<<i);
memo.clear();
return dp(s[59]+1);
}
# | 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... |