#5632. [GCJ 2008 AMER SemiFinal] Test Passing Probability

    ID: 5632 传统题 6000ms 1024MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>P13480动态规划 DP2008Special Judge概率论Google Code Jam

[GCJ 2008 AMER SemiFinal] Test Passing Probability

[GCJ 2008 AMER SemiFinal] Test Passing Probability

题目描述

Dave is taking a multiple choice test on the Internet. Dave possibly gets many opportunities to submit his answers to the test, but he passes only if he gets all the questions correct. He must answer every question on the test to make a submission. The only information he receives after he submits is whether he has passed.

For each question, he estimates the probability that each of 4 responses is correct, independent of his responses to other questions. Given a fixed number of submissions he can make, Dave wants to choose his responses so that he maximizes the probability of passing the test.

What is the probability that Dave will pass the test if he chooses his responses optimally?

输入格式

The first line of input gives the number of cases, $C$. $C$ test cases follow.

Each test case starts with a line containing MM and QQ. Dave is allowed to make MM submissions to solve the test. There are QQ questions on the test. QQ lines follow, each containing 4 probabilities of correctness. There will be at most 6 digits after the decimal point. The probabilities for each line are non-negative and sum to 1.

输出格式

For each test case, output one line containing "Case #$X$: $Y$" where $X$ is the number of the test case (starting from 1), and $Y$ is the probability of success.

Answers with a relative or absolute error of at most 10−610^{-6} will be considered correct.

3
10 2
0.25 0.25 0.25 0.25
0.25 0.25 0.25 0.25
64 3
0.3 0.4 0.0 0.3
1.0 0.0 0.0 0.0
0.2 0.2 0.2 0.4
3 2
0.5 0.17 0.17 0.16
0.5 0.25 0.25 0.0
Case #1: 0.625
Case #2: 1.0
Case #3: 0.5

提示

**Limits**
  • 1⩽C⩽1001 \leqslant C \leqslant 100

Small dataset (Test set 1 - Visible)

  • Time limit: 60 6 seconds.
  • 1⩽Q⩽61 \leqslant Q \leqslant 6
  • 1⩽M⩽10001 \leqslant M \leqslant 1000

Large dataset (Test set 2 - Hidden)

  • Time limit: 180 18 seconds.
  • 1⩽Q⩽301 \leqslant Q \leqslant 30
  • 1⩽M⩽100001 \leqslant M \leqslant 10000 标签: P13480|动态规划 DP|2008|Special Judge|概率论|Google Code Jam

来源

P13480|[GCJ 2008 AMER SemiFinal] Test Passing Probability