提交时间:2022-07-20 11:53:31

运行 ID: 52778

#include<bits/stdc++.h> using namespace std; int n,a,b,x[25],ans1; long long ans2(1); int main(){ scanf("%d%d%d",&n,&a,&b); for(int i(1);i<=n;++i) scanf("%d",x+i); for(int k(1);k<=n;++k) for(int i(1);i<=n;++i) if(x[i]^i){ swap(x[i],x[x[i]]); ++ans1;break; } for(int i(2);i<=n;++i) ans2*=i; printf("%lld.00000000000000000000\n",(b>n*a)?1ll*ans1*a:min(1ll*ans1*a,ans2*b)); return 0; }