提交时间:2022-07-20 12:02:00

运行 ID: 52825

#include<bits/stdc++.h> #define fst(a,b,c) for(int a=(b);a<=(c);a++) using namespace std; const int N=20; int n,a,b; namespace BL{ int ans,fa[N]; int find(int x){return (fa[x]==x)?x:fa[x]=find(fa[x]);} void Main(){ int x; ans=n; fst(i,1,n) fa[i]=i; fst(i,1,n) scanf("%d",&x),fa[find(i)]=find(x); fst(i,1,n) if(find(i)==i) ans--; printf("%.10lf\n",1.0*ans*a); return; } } int main(){ // freopen("permutation.in","r",stdin); // freopen("permutation.out","w",stdout); scanf("%d%d%d",&n,&a,&b); BL::Main(); return 0; }