提交时间:2022-07-20 11:51:43

运行 ID: 52748

#include<bits/stdc++.h> #define ll long long using namespace std; inline ll read(){ ll x=0,f=1,c=getchar(); while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar(); while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f; } ll n,a,b,A[21],cnt; bool vis[21]; inline void dfs(int x){ vis[x]=1; if(!vis[A[x]])dfs(A[x]); } int main(){ n=read(),a=read(),b=read(); for(int i=1;i<=n;i++)A[i]=read(); for(int i=1;i<=n;i++) if(!vis[i]) cnt++,dfs(i); printf("%d.00000000000000",a*(n-cnt)); return 0; }