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 sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
typedef long long lint;
typedef pair<lint,lint> ii;
map<lint,lint> memo;
lint S[65];
lint dp(lint n){ ///number of good things <n
if(n <= 0) return 0;
if(n == 1) return 1;
if(memo.find(n) != memo.end()) return memo[n];
lint a = 60;
while(((1LL<<a)&(n-1))==0) a--;
lint A = (1LL<<a);
lint B = min(n,S[a]+1) - A;
lint res = dp(A)+dp(B);
memo[n] = res;
return res;
}
lint count_tastiness(lint x, vector<lint> a){
for(lint i = 0;i < 60;i++) S[i] = 0;
for(lint i = 0;i < sz(a);i++) S[i] += (a[i]<<i);
for(lint i = 1;i < 60;i++) S[i] += S[i-1];
for(lint i = 0;i < 60;i++) S[i] /= x;
memo.clear();
return dp(1LL<<60LL);
}
# | 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... |