Mr. White, a fat man, now is crazy about a game
named ``Dance, Dance, Revolution". But his dance skill is so poor that he could
not dance a dance, eve...
分类:
其他好文 时间:
2014-05-15 16:57:57
阅读次数:
502
OJ题目:click here~~
题目分析:1……n按顺序围成一个圈,1与n相邻。交换相邻两个数算1步。至少需要多少步,得到一个逆方向的1……n的圈。
分两半,使用冒泡排序,排成逆序的交换次数之和即为结果。
AC_CODE
int f(int n){
return n*(n - 1)/2;
}
int main(){
int n , t;
cin >> t;
...
分类:
其他好文 时间:
2014-05-06 23:15:55
阅读次数:
301