题目来源(洛谷P1908 逆序对)
题目链接:
求逆序对的数目https://www.luogu.com.cn/problem/P1908
逆序对数目的求解方法,一种是基于冒泡排序,另一种是基于归并排序。
基于冒泡排序的算法:(O(n^2))
#include<cstdio>
int num[500001];
int tot;
unsigned long long sum=0;
inline int read(){
int res=0;
char c=getchar();
while(c>='0' && c<='9'){
res=(res<<1)+(res<<3)+(c^48);
c=getchar();
}
return res;
}
inline void write(unsigned long long num){
if(num!=0){
write(num/10);
putchar((num%10)^48);
}
}
int main(){
bool check;
tot=