이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
long long count_tastiness(long long x, std::vector <long long> a) {
std::vector <long long> tmp(61, 0);
a.insert(a.end(), tmp.begin(), tmp.end());
std::vector <long long> pre(61, 0);
pre[0] = a[0];
for (int i = 1; i <= 60; i++) {
pre[i] = pre[i - 1] + a[i] * (1LL << i);
}
std::map <long long, long long> dp;
auto f = [&] (auto&& self, long long val) -> long long {
if (val < 0LL) {
return 0;
}
if (!val) {
return 1LL;
}
if (dp.count(val)) {
return dp[val];
}
return dp[val] = self(self, (1LL << (63LL - __builtin_clzll(val))) - 1) + self(self, std::min(val, pre[63 - __builtin_clzll(val)] / x) - (1LL << (63LL - __builtin_clzll(val))));
};
return f(f, 1LL << 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... |