提交时间:2022-07-20 12:04:33

运行 ID: 52859

#include<iostream> #include<iomanip> using namespace std; int s[30]; long long jc[21]={0,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; cin>>n>>a>>b; for(int i=1;i<=n;i++){ cin>>s[i]; } long long sum=0; for(int i=1;i<=n;i++){ if(s[i]!=i){ for(int j=1;j<=n;j++){ if(s[j]==i){ s[j]=s[i]; s[i]=i; sum+=a; } } } } long long ans=b*jc[n]; cout<<min(ans,sum)<<".0000000000000000000"; }