CodeForces 623D Birthday (贪心)
2016-07-17 13:21
363 查看
// // main.cpp // Main // // Created by czk on 16/7/13. // Copyright © 2016年 czk. All rights reserved. // #include <iostream> #include <cstdio> #include <cstring> using namespace std; #define N 120 double p ; int n; int c ; double pp ; double P[3000030]; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { scanf("%lf", &p[i]); p[i] /= 100; } for(int i = 1; i <= n; ++i) { pp[i] = 1 - p[i]; } double ans = 0; for(int t = n; t <= 300000; ++t) { P[t] = 1; for(int i = 1; i <= n; ++i) { P[t] *= 1 - pp[i]; } ans += t * (P[t] - P[t - 1]); int u = -1; double mx = 0; double sum = 1; for(int i = 1; i <= n; ++i) { sum *= 1 - pp[i]; } for(int i = 1; i <= n; ++i) { if(sum / (1 - pp[i]) * pp[i] * p[i] > mx) { mx = sum / (1 - pp[i]) * pp[i] * p[i]; u = i; } } c[u]++; pp[u] *= 1 - p[u]; } printf("%.12lf\n", ans); return 0; }
相关文章推荐
- An error has occurred,See error log for more details
- CANoe 入门 Step by step系列(一)
- Chrome使用技巧(几个月的心得)
- 表达式求值
- Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost
- 最少转弯
- APUE(7)---进程环境
- Kafka入门经典教程
- HTML 5 <progress>进度标签
- html5语义化标签
- linux系统硬件配置查看指令
- Anaconda 镜像
- L1-025. 正整数A+B
- window or linux 开机黑屏,只有光标在闪
- Android UI 自动化测试
- tp_link路由器 重新设置
- _软件测试计划范例
- 操作系统之存储器管理
- CANoe CAPL语言Step2
- 软件总体测试计划