22825_SettlersofCatan

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

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

Pro.ID

22825

Title

Settlers of Catan

Title链接

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

AC

8

Submit

19

Ratio

42.11%

时间&空间限制

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

    The popular board game "Settlers of Catan" starts by creating a random board. This board consists of hexagonal resource tiles containing five different resources: clay, lumber, wool, grain, and ore. For simplicity, we will denote these by the numbers 1 to 5.

    Random boards, however, often have multiple equal resource tiles next to each other. This annoys some players. Therefore, we have invented a new way of creating the playing board. Starting in the middle and spiraling outwards, each time we add a new tile to the board we choose the resource of the tile according to the following rules:

    1. the new tile must be different from its neighboring tiles on the board so far;

    2. in case multiple tiles are possible, we choose a resource that occurs the least number of times on the board so far;

    3. in case multiple tiles are still possible, the new resource must have the lowest number possible.

    The figure underneath shows how to spiral outwards and which resource tiles are chosen first. We are curious what the number of the resource is on the n-th tile that is added to the board (starting with n = 1).

    输入

    On the first line of the input there is one integer c (1 ≤ c ≤ 200), the number of test cases. Each following test case consists of a single line with one integer n (1 ≤ n ≤ 10000), the number of the tile we are curious about.

    输出

    Description

    The popular board game "Settlers of Catan" starts by creating a random board. This board consists of hexagonal resource tiles containing five different resources: clay, lumber, wool, grain, and ore. For simplicity, we will denote these by the numbers 1 to 5.

    Random boards, however, often have multiple equal resource tiles next to each other. This annoys some players. Therefore, we have invented a new way of creating the playing board. Starting in the middle and spiraling outwards, each time we add a new tile to the board we choose the resource of the tile according to the following rules:

    1. the new tile must be different from its neighboring tiles on the board so far;

    2. in case multiple tiles are possible, we choose a resource that occurs the least number of times on the board so far;

    3. in case multiple tiles are still possible, the new resource must have the lowest number possible.

    The figure underneath shows how to spiral outwards and which resource tiles are chosen first. We are curious what the number of the resource is on the n-th tile that is added to the board (starting with n = 1).

    Input

    On the first line of the input there is one integer c (1 ≤ c ≤ 200), the number of test cases. Each following test case consists of a single line with one integer n (1 ≤ n ≤ 10000), the number of the tile we are curious about.

    Output

    For each test case, print a single line with one integer, specifying the resource of the n-th tile.

    Sample Input

    4
    1
    4
    10
    100

    Sample Output

    1
    4
    5
    5

    Source

    样例输入

    4
    1
    4
    10
    100

    样例输出

    1
    4
    5
    5

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部