康托展开 未完成
作者:互联网
#include<iostream> #include<algorithm> #include<cstring> typedef unsigned long long ull; using namespace std; const int N = 1000002; long fac[]={1,1,2,6,24,120,720,5040,40320,362820}; int n,a[N]; int cantor(int str[],int n){ ull res=0; for (int i = 0; i < n; i++) { int cot=0; for (int j = i+1; j < n; j++) { if(str[i]>str[j]) cot++; } res+=cot*fac[n-i-1]; } return (res+1)%998244353; } int main(){ ios::sync_with_stdio(false); cin>>n; for (int i = 0; i < n; i++) { cin>>a[i]; } cout<<cantor(a,n)<<endl; return 0; }
标签:cot,int,res,long,++,完成,include,展开,康托 来源: https://www.cnblogs.com/limitedInfinite/p/14772702.html