提交时间:2022-07-20 12:02:44
运行 ID: 52841
#include <stdio.h> #include <stdint.h> #include <inttypes.h> typedef int32_t T; #define P "%"PRIi32 T s[21]; void swap(T *a,T *b){T t=*a;*a=*b;*b=t;} main(){T n,a,b,c=0,i,t;scanf(P P P,&n,&a,&b);for(i=1;i<=n;i++)scanf(P,s+i); for(t=1;t<=n;t++)for(i=1;i<=n;i++)if(s[i]!=i){swap(s+i,s+s[i]);c++;} printf(P"\n",c*a);return 0;}