南昌大学航天杯第二届程序设计竞赛校赛网络同步赛 C

链接:https://www.nowcoder.com/acm/contest/122/C
来源:牛客网

题目描述

一张地图上有有N个城市,他们可以通过双向道路互相连接,但是每两座城市只能有一条双向道路互相连接。

现在我们想要满足条件“地图中不能有任意三个城市可以互相直达”,请问满足这个条件的最大道路数是多少?

输入描述:

多组输入

每组输入一个N(1<=N<=1000)

输出描述:

每组答案输出一行
示例1

输入

4
2
3

输出

4
1
2
 1 def sol():
 2     List = [0]
 3     for i in range(10000):
 4         List.append(0)
 5 
 6     for i in range(1,10000):
 7         List[i+1] = List[i] + int((i+1)/2)
 8         
 9     return List
10 while True:
11     try:
12         a = int(input())
13         List = sol()
14         print(List[a])
15 
16     except EOFError:
17         break  

猜你喜欢

转载自www.cnblogs.com/yinghualuowu/p/9063320.html