A、Airport Connecting Management

来源:互联网 发布:瑞芯微电子 知乎 编辑:程序博客网 时间:2024/04/28 23:35

                                                                                              Problem A:Airport Connecting Management

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





添加一个机场至少加一道航班


#include<iostream>using namespace std;int main(){int t,n;cin>>t;while(t--){cin>>n;if(n<2)cout<<'0'<<endl;else cout<<n-1<<endl;}return 0;}


0 0