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 <cstdio>
#include <algorithm>
using namespace std;
const int mnum = (1 << 20) + 1;
int N;
double pct[mnum];
double exd[mnum];
inline int last(int n) { return n&(-n); }
inline int amt(int n) { return __builtin_popcount(n & ((1<<N)-1)); }
void fill_table()
{
for (int i=2; i<=N; i++) {
for (int n=1; n < (1<<N); n++) {
if (amt(n)==i) {
int b1 = n-last(n), b2 = last(n);
pct[n] = pct[b1] + pct[b2] - pct[b1] * pct[b2];
exd[n] = exd[b1] + exd[b2] - ((pct[b1] * exd[b2] * amt(b1) + pct[b2] * exd[b1] * amt(b2)) / double(amt(b1) + amt(b2)));
}
}
}
}
int main()
{
scanf("%d", &N);
for (int i=1, c=0; c<N; c++, i = i<<1) {
int a, b;
scanf("%d%d", &a, &b);
pct[i] = (double)a / 100.0;
exd[i] = (double)a * (double)b / 100.0;
}
fill_table();
double res = 0.0;
for (int i=1; i < (1<<N); i++)
res = max(exd[i], res);
printf("%.10f", res);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |