题目链接:https://vjudge.net/contest/125308#problem/D
这题要求错误的方式有多少种,就是一个错排公式,记得公式就行 a[i]=(i-1)*(a[i-1]+a[i-2]);
AC代码:
1 #include<stdio.h> 2 long long a[21] = {0,0,1,2,9,44,265,1854,14833,133496,1334961,14684570,176214841,2290792932,32071101049,481066515734,7697064251745,130850092279664,2355301661033953,44750731559645106,895014631192902121}; 3 int main() 4 { 5 int x; //直接打表 6 while(~scanf("%d",&x)&&x) 7 { 8 printf("%lld ",a[x]); 9 } 10 return 0; 11 }