摘要: POJ2299,题目链接http://poj.org/problem?id=2299题意:给出长度为n的序列,每次只能交换相邻的两个元素,问至少要交换几次才使得该序列为递增序列。思路:其实就是求逆序数,那么直接向到的就是冒泡了,交换一次,记录一次即可。但是n的范围达到50W,冒泡O(n^2)的复杂度... 阅读全文
posted @ 2014-06-15 19:07 、拂晓 阅读(1168) 评论(0) 推荐(0) 编辑
摘要: POJ2388,题目链接http://poj.org/problem?id=2388题意:水题一道给定n个数,输出中间值,可以用sort,干脆快捷。代码://396K 32MS#include #include int buf[10000];int main(){ int cowsNum; scan... 阅读全文
posted @ 2014-06-15 18:49 、拂晓 阅读(225) 评论(0) 推荐(0) 编辑