22139_Endthispainfulcontestwithasimpleproble

2022-5-16 18:21| 发布者: Hocassian| 查看: 29| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506142768900-Problem List-采集的数据-后羿采集器.html

Pro.ID

22139

Title

End this painful contest with a simple problem

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22139

AC

2

Submit

2

Ratio

100.00%

时间&空间限制

  • Time Limit: 10000/5000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Building 132, Room 605 was a strange dorm in south campus. All guys lived in it are gluttonous and lazy. The laziest two guys are Oper and Nicholas. They are too lazy to go to dining hall to have a meal, so they often called take-away. But as they lived on the sixth floor, nobody was willing to go downstairs to get the take-away. Therefore, they came up with a solution to solve this problem.

    They take two decks of cards, each deck with same number of cards. Every card has a number on it, which may be different from others. At the beginning, they each selects a deck of cards for himself, and their scores are both 0, Each operates his cards as follows: He randomly selects a card, adds its number to his score, puts it back and shuffles the cards. After N repeats, the one with higher score wins. The loser has to go downstairs for the take-away. Given the number on each card they own and N, you're asked to figure out the probability that Oper wins.

    输入

    The first line contains an integer T, which is the number of test cases.

    For each test case, there will be 4 lines.

    The first line contains an integer M, which is the number of each deck of cards ( 1 ≤ M ≤ 100 ).

    The second line contains M positive integers which describe the number on every card Oper owns. The third line contains M positive integers which describe the number on every card Nicholas owns. These numbers will not exceed 50.

    The last line contains an integer N, which is the number of cards they randomly select respectively ( 1 ≤ N ≤ 50 ).

    输出

    Description

    Building 132, Room 605 was a strange dorm in south campus. All guys lived in it are gluttonous and lazy. The laziest two guys are Oper and Nicholas. They are too lazy to go to dining hall to have a meal, so they often called take-away. But as they lived on the sixth floor, nobody was willing to go downstairs to get the take-away. Therefore, they came up with a solution to solve this problem.

    They take two decks of cards, each deck with same number of cards. Every card has a number on it, which may be different from others. At the beginning, they each selects a deck of cards for himself, and their scores are both 0, Each operates his cards as follows: He randomly selects a card, adds its number to his score, puts it back and shuffles the cards. After N repeats, the one with higher score wins. The loser has to go downstairs for the take-away. Given the number on each card they own and N, you're asked to figure out the probability that Oper wins.

    Input

    The first line contains an integer T, which is the number of test cases.

    For each test case, there will be 4 lines.

    The first line contains an integer M, which is the number of each deck of cards ( 1 ≤ M ≤ 100 ).

    The second line contains M positive integers which describe the number on every card Oper owns. The third line contains M positive integers which describe the number on every card Nicholas owns. These numbers will not exceed 50.

    The last line contains an integer N, which is the number of cards they randomly select respectively ( 1 ≤ N ≤ 50 ).

    Output

    For each test case, output a line contains the probability Oper wins. Round the numbers in the output to 6 digits after decimal point.

    Sample Input

    1
    10
    5 9 6 12 13 15 52 11 11 11
    8 9 6 3 2 1 85 9 2 3
    15

    Sample Output

    0.620092

    Source

    样例输入

    1
    10
    5 9 6 12 13 15 52 11 11 11
    8 9 6 3 2 1 85 9 2 3
    15

    样例输出

    0.620092

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部