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 }
时间: 2024-11-08 19:26:01