hdu 5122】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5122 解题报告:定义一种排序算法,每一轮可以随机找一个数,把这个数与后面的比这个数小的交换,一直往后判断,直到后面没有比这个数小的,这样称为一轮,现在给定一个长度为n的序列,要你求,至少要经过多少轮,可以使这个序列成为有序的. 由于只能跟后面的数进行比较,所以我只要统计后面的数有比这个数小的数的个数就可以了.从后往前扫一遍,每次更新当前最小的. #include<cstdio> #include&…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5122 Problem Description Matt's friend K.Bro is an ACMer.Yesterday, K.Bro learnt an algorithm: Bubble sort. Bubble sort will compare each pair of adjacent items and swap them if they are in the wrong or…
只要一个数的后面有比它小的数,这个数就要移,于是从后往前一趟遍历,记录一下这些数的个数就可以了. #include"iostream" #include"stdio.h" #include"string.h" #include"cmath" #include"algorithm" #include"queue" #include"stack" #include&quo…
K.Bro Sorting Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 2510 Accepted Submission(s): 1174 Problem Description Matt's friend K.Bro is an ACMer. Yesterday, K.Bro learnt an algorithm: Bubble…
Matt's friend K.Bro is an ACMer.Yesterday, K.Bro learnt an algorithm: Bubble sort. Bubble sort will compare each pair of adjacent items and swap them if they are in the wrong order. The process repeats until no swap is needed.Today, K.Bro comes up wi…
题意: 从n个数中任选一些数,问有多少种选法使他们异或和不小于M 思路: dp[i][j]表示选i个数异或和为j,则方程dp[i][j] = dp[i-1][j](不选i)+ dp[i-1][j^a[i]] #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; typedef long long ll; const…
把一个序列按从小到大排序 要执行多少次操作 只需要从右往左统计,并且不断更新最小值,若当前数为最小值,则将最小值更新为当前数,否则sum+1 Sample Input255 4 3 2 155 1 2 3 4 Sample OutputCase #1: 4Case #2: 1 # include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include…
传送门 对于错想成lis的解法,提供一组反例 1 3 4 2 5同时对于这次案例也可以观察出解法:对于每一个数,如果存在比它小的数在它后面,它势必需要移动,因为只能小的数无法向右移动,而且每一次移动都必然可以使得这个数到达正确位置,这是根据题意而得的 #include<queue> #include<cmath> #include<cstdio> #include<cstring> #include<cstdlib> #include<io…
Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7194    Accepted Submission(s): 3345 Problem Description 话说上回讲到海东集团面临内外交困,公司的元老也只剩下XHD夫妇二人了.显然,作为多年拼搏的商人,XHD不会坐以待毙的.  一天,当他正在苦思冥想解困良策的…
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int jc[100003]; int p; int ipow(int x, int b) { ll t = 1, w = x;…