21858_SquareLottery

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

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

Pro.ID

21858

Title

Square Lottery

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    The government of the United Republic of Little Tower is developing a new kind of lottery. The main purpose of the lottery is to raise money to build Little Tower's Olympic Stadium, for an attendance of 400,000 people. The stadium is strategic for Little Tower's proposal to host the World Cup Finals in 2078.

    The lottery will run weekly. Each week, tickets in the form of square cards will be sold. Each ticket will have squares with printed numbers within, in a sequence of N rows and N columns, as shown in Figure 1.

    In each ticket no number appears twice, and therefore all numbers from 1 to N 2 are present (in random positions). No two tickets sold in the same week will be equal. Nevertheless, all possible different tickets will be sold, since Little Tower's citizens love lotteries. Tickets will be sold for T$1.00 (one Torreal, Little Tower's monetary unit).

    To choose the winner(s), four numbers (between 1 and N 2) will be picked randomly, and the ticket(s) whose chosen numbers positions are corners of a square will be awarded the prize money. For example, the ticket shown in Figure 1 is a winning ticket if the numbers picked are (6, 3, 2, 9), (1, 4, 2, 5) or (7, 8, 9, 6), but it is not a winning ticket if the numbers picked are (1, 7, 2, 9). If more than one ticket is a winner, customers who bought those tickets will share the week's lottery prize.

    The government of Little Tower asks your help to determine the prize value to be payed for each winning ticket, for a given N, and a given percentage, over the total amount received for the tickets, that the government wants to pay as prizes.

    输入

    Input will contain several test cases. Each test case is described in a line containing two integers N and P, representing respectively the number of rows (and columns) of tickets, and the percentage of the money received that will be payed as prize (2 ≤ N ≤ 100 and 0 ≤ P ≤ 100). The end of input is indicated by N = P = 0.

    输出

    Description

    The government of the United Republic of Little Tower is developing a new kind of lottery. The main purpose of the lottery is to raise money to build Little Tower's Olympic Stadium, for an attendance of 400,000 people. The stadium is strategic for Little Tower's proposal to host the World Cup Finals in 2078.

    The lottery will run weekly. Each week, tickets in the form of square cards will be sold. Each ticket will have squares with printed numbers within, in a sequence of N rows and N columns, as shown in Figure 1.

    In each ticket no number appears twice, and therefore all numbers from 1 to N 2 are present (in random positions). No two tickets sold in the same week will be equal. Nevertheless, all possible different tickets will be sold, since Little Tower's citizens love lotteries. Tickets will be sold for T$1.00 (one Torreal, Little Tower's monetary unit).

    To choose the winner(s), four numbers (between 1 and N 2) will be picked randomly, and the ticket(s) whose chosen numbers positions are corners of a square will be awarded the prize money. For example, the ticket shown in Figure 1 is a winning ticket if the numbers picked are (6, 3, 2, 9), (1, 4, 2, 5) or (7, 8, 9, 6), but it is not a winning ticket if the numbers picked are (1, 7, 2, 9). If more than one ticket is a winner, customers who bought those tickets will share the week's lottery prize.

    The government of Little Tower asks your help to determine the prize value to be payed for each winning ticket, for a given N, and a given percentage, over the total amount received for the tickets, that the government wants to pay as prizes.

    Input

    Input will contain several test cases. Each test case is described in a line containing two integers N and P, representing respectively the number of rows (and columns) of tickets, and the percentage of the money received that will be payed as prize (2 ≤ N ≤ 100 and 0 ≤ P ≤ 100). The end of input is indicated by N = P = 0.

    Output

    For each test case in the input your program should produce one line of output, containing a real value representing the prize to be payed to each winning ticket. The prize value must be printed with twodigit precision, and the last decimal digit must be rounded. The input will not contain test cases where differences in rounding are significant.

    Sample Input

    2 100
    2 80
    3 50
    0 0

    Sample Output

    1.00
    0.80
    10.50

    Source

    样例输入

    2 100
    2 80
    3 50
    0 0

    样例输出

    1.00
    0.80
    10.50

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部