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;
#define vi vector<int>
#define int long long
#define pb push_back
#define ins insert
#define sz(x) (int)((x).size())
long long count_tastiness(long long x, std::vector<long long> b) {
while (sz(b) < 61) b.push_back(0);
int lim [61+1];
int sum = 0;
for (int i = 0; i < 61; i++) {
sum += (1LL<<i)*b[i];
lim[i] = min(sum, (1LL<<(i+1))-1);
}
lim[61] = (1LL<<61)-1;
int dp [61][61+1];
for (int i = 0; i <= 61; i++) {
if (lim[0] == 0 || (lim[i]&1) == 0) {
dp[0][i] = 1;
}
else {
dp[0][i] = 2;
}
}
for (int i = 1; i < 61; i++) for (int j = 0; j <= 61; j++) {
int resultingMask = (1LL<<(i))-1;
int newJ = j;
if ((lim[i]&resultingMask) < (lim[j]&resultingMask)) {
newJ = i;
}
dp[i][j] = 0;
if (((lim[i]>>i)&1) && ((lim[j]>>i)&1)) {
dp[i][j] += dp[i-1][newJ]; // add one
dp[i][j] += dp[i-1][61]; // add zero
}
else {
dp[i][j] += dp[i-1][newJ]; // add zero
}
}
int res = dp[61-1][61];
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... |