Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

几乎是O(1)了,不用dp……

Posted by wingkou at 2016-01-26 17:17:34 on Problem 3744
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator