Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
几乎是O(1)了,不用dp……#include <algorithm> #include <cmath> #include <cstdio> using namespace std; int main() { int n, mine[16]; double p; while (scanf("%d%lf", &n, &p) == 2) { for (int i = 0; i < n; i++) scanf("%d", mine + i); sort(mine, mine + n); int cur = 1; double curp = 1; for (int i = 0; i < n; i++) { curp *= 1 - ((1 - p) * pow(p - 1, mine[i] - cur) + 1) / (2 - p); cur = mine[i] + 1; } printf("%.7f\n", curp); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator