以前一般用树状数组和线段树做这种题 这次换个思路试试,归并排序! #include<cstdio>#include<cstring>#include<algorithm>using namespace std;typedef long long LL;const int maxn = 111111;int n;int array[maxn];int tmp[maxn];L
This way 题意: 给你一个数组a,设r为a的某种排序, t ( r ) t(r) t(r)为r中逆序对的个数,问你 ∑ b t ( r ) \sum{b^{t(r)}} ∑bt(r)是多少 题解: 值不重复的时候,我们考虑第i大的数,它和前面i-1个数组成的逆序对的所有可能是0-(i-1) 那么答案就乘上 ( 1 + b + b 2 + . . . + b i − 1 ) (1+b
Divide and Conquer The attached le Q8.txt contains 100,000 integers between 1 and 100,000 (each row has a single integer), the order of these integers is random and no integer is repeated. 刚写程序是用的