U282278 逆序对次方和次方逆序对
题目背景
参考资料:
[「GLR-R3」立春](https://www.luogu.com.cn/problem/P8474)
[【ULR #2】哈希杀手](https://uoj.ac/contest/64/problem/658)
[「LAOI-2」红岸基地](https://www.luogu.com.cn/problem/T312175?contestId=98660) 和 [Sol](https://www.luogu.com.cn/blog/writeSTL/solution-children-and-homo)
[inv](http://148.70.30.208:4000/2022%E7%9C%81%E9%80%89%E8%81%94%E8%80%83-inv/)
题目描述
设 $P$ 为任意一个长度为 $n$ 的排列,$\tau(P)$ 为其中的逆序对个数,求
$$
\sum_P \left( k^{\tau(P)} + \tau^k(P) \right)
$$
输入格式
第一部分:$nk \le 10^9$,否则输出 0
输出格式
无
说明/提示
$2 \le k \le 10^5, n \le 10^{11}$
期望时间复杂度:$o(\sqrt n \log n + k \log k)$
[Sol](https://www.luogu.com.cn/blog/NaCly-Fish-blog/glr-r3a-sol)