Question:
Description
Download as PDF
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
3
4
5
6
Sample Output
2
4
6
题意大意:许多人坐在一起,每次交换只能与邻近的交换,问要交换多少次才能使相邻的人互换,(即使左边邻居变为右边邻居)
这道题我不知道怎么做,在别人讲了以后还是不知道代码怎么来的。
(http://acm.hust.edu.cn/vjudge/contest/121559#problem/M)
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n,t;
cin>>t;
for(int i=0;i<t;i++)
{
cin>>n;
cout<<n/2*((n-1)/2)<<endl;
}
return 0;
}
代码虽短,但却并不知道怎么来的