Logo
(追記) (追記ここまで)

5226번 - Shut The Box II 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB72250.000%

문제

http://www.cs.umd.edu/Outreach/hsContest12/questions/all.pdf

입력

The Avengers are still bored on their way to the Collector’s hiding place, and are continuing to play Shut the Box. Unfortunately for Dr. Banner, the strategy that he was using with your help is not turning out to be a very good one, and he is losing most of the games. He is halfway to transforming into the Hulk, and you need to calm him down by finding the best move at any given point, defined to be the one that maximizes the probability of eventually shutting the box.

Assume that the dice are fair (i.e., with two dice, all of the 36 possibilities are equally likely). Keep in mind the twist mentioned earlier: when the total of the open cards is ≤ 6, only one die is used.

For example, say the current open cards are: 1, 2, and 3, and the rolled total = 3. There are 2 moves:

  • Shut 1 and 2: In this case, we are left with 3. The probability that we will shut the box is then equal to the probability that we roll a 3 on the next try. Assuming fair dice (and keeping in mind we are only using 1 die), the probability = 1/6 = 0.166666.
  • Shut 3: Then we are left with 1 and 2, and the analysis is a bit more complicated. However, we can show the probability of eventually shutting the box to be somewhat higher in this case. We state the computation here without derivation: 1/6 + 2/6 * 1/6 = 0.2222222. We should choose this move.

출력

The first line in the test data file contains the number of test cases (< 100). After that, each line contains one test case: the first entry on each line is the rolled total (called target), and the next entry is the number of open cards n. The following n entries denote the open cards in the ascending order.

제한

For each test case, you are to output the move that maximizes the probability of eventually shutting the box, or output that there is no legal move. If there is a move, you also need to list out the probability of shutting the box moving forward. The exact form is shown below.

출력 형식

정확한 출력 형식은 제출에서 언어를 Java로 설정하면 확인할 수 있다.

예제 입력 1

4
3 3 1 2 4
3 3 1 2 3
6 3 1 2 3
8 4 1 2 3 9

예제 출력 1

The best move is: 1 2, and probability of shutting = 0.1667
The best move is: 3, and probability of shutting = 0.2222
The best move is: 1 2 3, and probability of shutting = 1
No move found.

힌트

출처

School > University of Maryland High School Programming Contest > HSPC 2012 7번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /