Sicily 1078. Beer Land
来源:互联网 发布:卖家淘宝店 编辑:程序博客网 时间:2024/06/05 19:57
1078. Beer Land
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
King ACM 2002 received some clear ground and some money through inheritance. Terms of the will and testament require the heir to build n towns. He was also required to build the least quantity of two-way roads between the towns such that one could travel from any town to any other town even if one road was closed under repair. Carefully, all such roads must be constructed as geometrically straight lines. Further, the condition that a traveller be able to get from one town to another (even with one road closed) needs to be satisfied by traversing the roads as straight lines in their entirety --- not stopping partway along one road to switch to another.
Because of rich soil in those lands, the future inhabitants of the place have decided to produce beer. On the crossroads (a crossroad is merey the intersection of two or more roads) the king plans to build beer stands (one stand per a crossroad). So, if three or four (or twenty) roads intersect in a single point, there's still only one appropriate place for a beer stand. The King must choose locations for the towns and the roads. You need to advise him so that he builds as many beer stands as possible.
Input
The first line of input contains the number of test cases. For each case there is a line containing a single integer n (1 <= n <= 32767). This represents the number of towns to be built.
Output
For each n, print a line containing the maximum number of beer stands possible to build.
Sample Input
3345
Sample Output
015
// Problem#: 1078// Submission#: 3403425// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include <stdio.h>#include <iostream>#include <vector>#include <string>#include <stack>#include <iomanip>#include <algorithm>#include <queue>#include <functional>#include <map>#include <string.h>#include <math.h>using namespace std;int main() { std::ios::sync_with_stdio(false); int caseNum; cin >> caseNum; while (caseNum--) { int n; cin >> n; if (n < 3) { cout << 0 << endl; continue; } cout << (n % 2 ? (n * (n - 3) / 2) : (n * (n - 4) / 2 + 1)) << endl; } return 0;}
- Sicily 1078. Beer Land
- POJ 1277 Beer Land 笔记
- Beer-v1
- Beer-v2
- Beer-v3
- Beer-v4
- 一、Beer
- zoj 3362 Beer Problem
- 3536 Beer Refrigerator
- poj 3536 (Beer Refrigerator)
- poj 3536 Beer Refrigerator
- poj 3536 Beer Refrigerator
- UVAL 6267 Beer Pressure
- Beer and Pretzel Caramels
- Grass Land
- Prime Land
- Prime Land
- Prime Land
- Sicily 1082. MANAGER
- 完全卸载oracle11g步骤
- fekwnfkoelwnfenkewfnk
- const void *a 与 void *const a 的区别
- JDK中rt.jar、tools.jar和dt.jar作用 (2014-03-20 09:32:51)
- Sicily 1078. Beer Land
- PLSQL collection 示例 之 Nested Tables
- Jeecms6中后台控制层Action如何将值传入前台视图层模板中的?
- php判断是否为手机浏览器
- Sicily 1033. City Road
- JavaScript 图片上传后base64转码直接显示
- Linux下nodejs安装
- 为什么JAVA要实现对象序列化
- 新鲜出炉的Android打包工具