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;}
- A、Airport Connecting Management
- Connecting to a eXtremeDB
- Connecting to a MySQL Database
- Connecting a Store toa Tree
- Airport
- A Famous Airport Manager dfs+打表
- Connecting to a GPS receiver using Bluetooth
- connecting scenes together to make a game
- Common Tasks :Connecting to a Host
- Common Tasks :Connecting to a Specified Host
- A guide to connecting Matlab with OpenCV
- scu A: Membership Management
- A Famous Airport Manager(dfs + 打表)
- GYM-101572A Airport Coffee(DP+单调队列)
- Remove a job without connecting as job owner
- NET: Connecting a TcpClient through an HTTP proxy with authentication
- CocosBuilder用户手册中文版:4a. Connecting with Cocos2d JS
- A memery management interface---Readme
- 查看进程PID与文件后缀名
- 周报(第三周)
- 数据结构-树(多叉树、二叉树、二叉搜索树、平衡二叉树、字典树、红黑树、线段树)
- 吃土豆
- Collection和Collections的区别
- A、Airport Connecting Management
- 反思总结-Ver0.0.1
- poj 3061 Subsequence(尺取法)
- NDK开发多模块的工作方式——设置、运用与思考
- ThreadLocal
- 关于codeblocks断点调试问题
- 《算法导论》笔记 第12章 *12.4 随机构造的二叉查找树
- 新概念英语在线视频
- 编程之美资格题目2 : 大神与三位小伙伴