Submission #18108

#TimeUsernameProblemLanguageResultExecution timeMemory
18108jun6873최적의 능력 구성 (kriii3_C)C++98
0 / 62
0 ms17468 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...