#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
long long b[65];
long long count_tastiness(long long x, std::vector<long long> a) {
long long S = 0;
int k = (int)a.size();
for(int i = 0; i < k; i ++){
S += (a[i]<<i);
}
if(x == 1){
for(int i = 0; i < k; i ++){
b[i] = a[i];
}
long long ans2 = 1;
long long val = 0;
long long mult = 1;
for(int i = 0; i < k; i ++){
val += a[i]*mult;
if(val >= 2*mult-1){
mult <<= 1;
}else{
ans2 *= (val+1);
mult = 1;
val = 0;
}
}
ans2 *= (val+1);
//printf("ans2=%lld\n", ans2);
//assert(ans == ans2);
return ans2;
}
long long ans = 1;
for(long long y = 1; y <= S/x; y ++){
bool boleh = true;
for(int j = 0; j < k; j ++){
b[j] = a[j];
}
for(long long i = 0; i < x; i ++){
long long rem = y;
for(int j = k-1; j >= 0; j --){
long long quotient = min(rem>>j, b[j]);
b[j] -= quotient;
rem -= (quotient << j);
}
if(rem != 0){
boleh = false;
break;
}
}
ans += boleh;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
15 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
15 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
4 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
97 ms |
364 KB |
Output is correct |
13 |
Correct |
84 ms |
364 KB |
Output is correct |
14 |
Correct |
86 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1082 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1090 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
15 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
15 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
4 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
97 ms |
364 KB |
Output is correct |
13 |
Correct |
84 ms |
364 KB |
Output is correct |
14 |
Correct |
86 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
1 ms |
364 KB |
Output is correct |
22 |
Correct |
1 ms |
364 KB |
Output is correct |
23 |
Correct |
1 ms |
364 KB |
Output is correct |
24 |
Execution timed out |
1082 ms |
364 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |