提交时间:2022-07-20 12:21:52

运行 ID: 52948

#include <bits/stdc++.h> using namespace std; long long ans; bool flag; long long Inv[21] = {1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368000,20922789888000,355687428096000,6402373705728000,121645100408832000,2432902008176640000}; int main() { int n,a,b; scanf("%d%d%d",&n,&a,&b); int Array[n + 1]; for(int i = 1;i <= n;i++) scanf("%d",&Array[i]),flag = (Array[i] != i ? false : true); if(flag) puts("0.0000000000"); else { for(int i = 1;i <= n;i++) { if(Array[i] == i) continue; for(int j = i + 1;j <= n;j++) if(Array[j] == i) swap(Array[i],Array[j]), ans++; } printf("%d",min(ans * a,Inv[n] * b)); puts(".0000000000"); } return 0; }