21661_AirportConnectingManagemen

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

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

Pro.ID

21661

Title

Airport Connecting Management

Title链接

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

AC

22

Submit

25

Ratio

88.00%

时间&空间限制

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

    There is a very beautiful country called ICPC (International Cleanest and Prettiest Country). It's really very clean and pretty, but not so convenient in traffic. This year, you are hired to take the following task called ACM (Airport Connecting Management):

    There are N cities in ICPC. Each city has exactly one airport. At first, there are no flights between them. You are asked to connect these airports by adding flights. The schedule must follow these rules:

    (1)  Each flight is a two-way service that directly connects two airports.

    (2)  No pair of airports can be connected by more than one flight.

    (3)  From a city, you can go to every other city by at most two flights (go directly or transfer by an intermediate city).

    Here comes the problem: What's the minimum number of flights you need to add to obey these rules?

    输入

    There are multiple test cases in this problem.

    The first line contains an integer T ( 1 ≤ T ≤ 10 ) telling the number of test cases.

    Each test case is an integer N ( 2 ≤ N ≤ 50 ) in a line indicating the number of cities.

    输出

    Description

    There is a very beautiful country called ICPC (International Cleanest and Prettiest Country). It's really very clean and pretty, but not so convenient in traffic. This year, you are hired to take the following task called ACM (Airport Connecting Management):

    There are N cities in ICPC. Each city has exactly one airport. At first, there are no flights between them. You are asked to connect these airports by adding flights. The schedule must follow these rules:

    (1)  Each flight is a two-way service that directly connects two airports.

    (2)  No pair of airports can be connected by more than one flight.

    (3)  From a city, you can go to every other city by at most two flights (go directly or transfer by an intermediate city).

    Here comes the problem: What's the minimum number of flights you need to add to obey these rules?

    Input

    There are multiple test cases in this problem.

    The first line contains an integer T ( 1 ≤ T ≤ 10 ) telling the number of test cases.

    Each test case is an integer N ( 2 ≤ N ≤ 50 ) in a line indicating the number of cities.

    Output

    For each test case, output an integer telling the minimum number of flights in a line.

    Sample Input

    2
    2
    3

    Sample Output

    1
    2

    Source

    样例输入

    2
    2
    3

    样例输出

    1
    2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部