이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
//#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
constexpr static int MXK = 62;
ll count_tastiness(ll x, vector<ll> a)
{
while (a.size() < MXK-1)
a.pb(0);
for (int i = 0; i < MXK; i++)
{
ll change = max<ll>((a[i] - x) / 2, 0);
a[i+1] += change;
a[i] -= change * 2;
}
vector<ll> pf(MXK, 0);
for (int i = 1; i < MXK; i++)
pf[i] = pf[i-1] + (a[i-1] << (i-1));
vector<vector<ll>> dp(MXK, vector<ll>(x+2, 0)); // Last open bit
dp[0][0] = 1;
for (int i = 1; i < MXK; i++)
for (int j = 0; j < i; j++)
for (int k = 0; k < x+2; k++)
if ((pf[i] - pf[j] + (k<<(j-1)) >= (x<<(i-1))))
dp[i][((pf[i]-pf[j]+(k<<(j-1)))>>(i-1))-x] += dp[j][k];
ll res = 0;
for (int i = 0; i < MXK; i++)
for (int j = 0; j < x + 2; j++)
res += dp[i][j];
debug(dp, res);
return res;
}
# | 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... |