首页 > 其他 > 详细

uvalive 2756 环形排列颠倒的次数

时间:2015-08-27 22:25:43      阅读:289      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!