poj 1455 Crazy tea party(数学)
来源:互联网 发布:免费的电子书软件 编辑:程序博客网 时间:2024/06/16 18:52
Crazy tea party
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7318 Accepted: 4973
Description
n participants of << crazy tea party >> sit around the table. Each minute one pair of neighbors can change their places. Find the minimum time (in minutes) required for all participants to sit in reverse order (so that left neighbors would become right, and right - left).
Input
The first line is the amount of tests. Each next line contains one integer n (1 <= n <= 32767) - the amount of crazy tea participants.
Output
For each number n of participants to crazy tea party print on the standard output, on a separate line, the minimum time required for all participants to sit in reverse order.
Sample Input
3456
Sample Output
246
solution:
设a = n / 2, b = n - a 则答案为a*(a - 1) / 2 + b*(b - 1) / 2)
#include<cstdio>using namespace std;int main(){int t,n;scanf("%d", &t);while (t--){scanf("%d", &n);int a = n / 2, b = n - a;printf("%d\n", a*(a - 1) / 2 + b*(b - 1) / 2);}return 0;}
0 1
- poj 1455 Crazy tea party(数学)
- POJ 1455 Crazy tea party
- poj 1455 Crazy tea party
- POJ 1455 Crazy tea party
- POJ 题目1455Crazy tea party(数学)
- zoj 1730 / poj 1455 Crazy Tea Party
- POJ 1455 Crazy tea party 笔记
- Crazy tea party-1455
- zoj 1730 || poj 1455 Crazy Tea Party(= =)
- POJ-1455(换位置)(Crazy tea party )
- POJ 1455 Crazy tea party 冒泡排序的想法
- poj 1455-Crazy tea Party-类似冒泡排序
- Poj.1455 Crazy tea party 2015/09/22
- Crazy Tea Party hoj poj 数学题
- Crazy tea party
- zoj1730-----------------Crazy Tea Party
- LA2756--Crazy tea party
- Crazy tea party
- hdu1233——还是畅通工程(最小生成树)
- 我的C++学习路线
- Android用命令行来操作模拟器
- 【LeetCode】Swap Nodes in Pairs 解题报告
- 用冒泡排序法实现qsort函数
- poj 1455 Crazy tea party(数学)
- Java学习-10.内部类
- spring mvc异常统一处理(ControllerAdvice注解)
- Java学习-11.持有对象
- POJ 1010--STAMPS
- 如何解决Ubuntu与Windows双系统时间不同步
- qint64 转QString
- JavaScript注意事项
- poj 2100 Graveyard Design(尺取)