/*
*由此题发现规律 就是冒泡排序的交换次数等于这个数列的逆序对 的对数!
*/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define MAXN 2000
using namespace std; int _m[MAXN]; int main()
{
//freopen("acm.acm","r",stdin);
int test;
int k;
int i;
int j;
int tem;
int ans;
int num;
cin>>test;
for(k = ; k <= test; ++ k)
{
ans = ;
cin>>num;
for(i = ; i < num; ++ i)
{
cin>>_m[i];
}
for(i = ; i < num-; ++ i)
{
for(j = ; j < num--i; ++ j)
{
if(_m[j] > _m[j+])
{
iter_swap(&_m[j],&_m[j+]);
++ ans;
}
}
}
cout<<"Scenario #"<<k<<":"<<endl<<ans<<endl<<endl;
}
}

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com

POJ 1804的更多相关文章

  1. POJ 1804 Brainman(5种解法,好题,【暴力】,【归并排序】,【线段树单点更新】,【树状数组】,【平衡树】)

    Brainman Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10575   Accepted: 5489 Descrip ...

  2. poj 1804 (nyoj 117)Brainman : 归并排序求逆序数

    点击打开链接 Brainman Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7810   Accepted: 4261 D ...

  3. POJ 1804 Brainman(归并排序)

    传送门 Description Background Raymond Babbitt drives his brother Charlie mad. Recently Raymond counted ...

  4. POJ 1804 Brainman

    Brainman Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7787   Accepted: 4247 Descript ...

  5. POJ 1804 逆序对数量 / 归并排序

    Brainman Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12175   Accepted: 6147 Descrip ...

  6. 【POJ 1804】 Brainman

    [题目链接] 点击打开链接 [算法] 本题是一个很经典的问题 : 归并排序求逆序对数,可以用分治算法解决 分治,分而治之,分治算法的思想就是将一个问题转化为若干个子问题,对这些子问题分别求解,最后, ...

  7. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

  8. (转)POJ题目分类

    初期:一.基本算法:     (1)枚举. (poj1753,poj2965)     (2)贪心(poj1328,poj2109,poj2586)     (3)递归和分治法.     (4)递推. ...

  9. poj分类

    初期: 一.基本算法:      (1)枚举. (poj1753,poj2965)      (2)贪心(poj1328,poj2109,poj2586)      (3)递归和分治法.      ( ...

随机推荐

  1. NOIP 2015复赛提高组Day2 T1==Codevs 4768 跳石头

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold  题目描述 Description 一年一度的“跳石头”比赛又要开始了! 这项比赛将在一条笔直的河道中进行,河道中 ...

  2. IPC with pipes, demo of 'popen'

    #include <stdio.h> #include <unistd.h> int main() { FILE* stream = popen ("sort&quo ...

  3. C语言成绩测试 ,水仙花数,打印星图

    #include <stdio.h>//输入输出头文件 #include<string.h> #include<stdlib.h> //局部被调用函数1 成绩检测 ...

  4. ant条件逻辑

    <condition property="sdk-folder" value="E:\android\android-sdk\adt-bundle-windows- ...

  5. brewhome - 第三方包管理工具

    最近对移动开发感兴趣,于是乎有了相当正式的理由购买了一台macbook pro 13. 我虽然以前没有使用过mac os,但是上手却很快,这大概跟我最近几年一直在使用linux系统有关吧.我平时上班时 ...

  6. CMD规范的函数与普通函数间调用

    /* * a.js * 普通的非cmd规范的js文件 */ function fun1(){ console.log("fun1"); //调用seajs模块中的fun1 seaj ...

  7. linux解压zip、bz、bz2、z、gz、tar(解包)

    zip: 压缩: zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b <工作目录>][-ll][-n <字尾字符串>][-t <日期时间>] ...

  8. JQ 选择器大全

    一.基本选择器 选择器 描 述 返回 示例 #id 根据给定id匹配一个元素 单个元素 $("#test") 选取id为test的元素 .class 根据给定类名匹配一个元素 集合 ...

  9. MySQL excel导入错误 Out of range value adjusted for column

    修改my.ini,将 sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"改为 sql ...

  10. 1066. Root of AVL Tree (25)

    An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child sub ...