QOJ.ac

QOJ

Time Limit: 5 s - 15 s Memory Limit: 1024 MB Total points: 19

#5777. Test Passing Probability

Statistics

Problem

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?

Input

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

Each test case starts with a line containing M and Q. Dave is allowed to make M submissions to solve the test. There are Q questions on the test. Q 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.

Output

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−6 will be considered correct.

Limits

Memory limit: 1GB.

1 ≤ C ≤ 100

Small dataset (Test set 1 - Visible; 5 Points)

Time limit: 60 5 seconds.

1 ≤ Q ≤ 6

1 ≤ M ≤ 1000

Large dataset (Test set 2 - Hidden; 14 Points)

Time limit: 180 15 seconds.

1 ≤ Q ≤ 30

1 ≤ M ≤ 10000

Sample

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
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.