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;
vector<long long> b;
bool check(long long x, long long y) {
int k = b.size();
__int128 prev = 0;
__int128 prod = x;
prod *= y;
for(int i=k-1; i>=0; i--) {
__int128 c = y / (1ll << i);
c *= x;
c -= prev / (1ll << i);
c = min(c, (__int128) b[i]);
prev += c * (1ll << i);
}
if(prev == prod) return 1;
return 0;
}
long long count_tastiness(long long x, std::vector<long long> a) {
b = a;
long long answer = 0;
for(long long y=0; y<=100000; y++) {
answer += check(x, y);
}
return answer;
}
# | 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... |