码迷,mamicode.com
首页 > 其他好文 > 详细

uvalive 2756 环形排列颠倒的次数

时间:2015-08-27 22:27:36      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:

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).

看起来挺简单的,不过还是不会证明。

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int main ()
 5 {
 6     int t;
 7     cin >> t;
 8     while ( t-- )
 9     {
10         int n;
11         cin >> n;
12         int m = ( n / 2 ) * ( n / 2 - 1 ) / 2 + ( ( n + 1 ) / 2 ) * ( ( n + 1 ) / 2 - 1 ) / 2;
13         cout << m << endl;
14     }
15     return 0;
16 }

 

uvalive 2756 环形排列颠倒的次数

标签:

原文地址:http://www.cnblogs.com/huoxiayu/p/4764529.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!