标签:
原文网址 http://blog.csdn.net/liwen_7/article/details/7646451
错排问题 就是一种递推式,不过它比较著名且常用,所以要熟记!
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16617 Accepted Submission(s):
6919
AC代码
#include<stdio.h> #include<string.h> int main() { int n,m,j,i,s,sum; long long fn[22]; fn[1]=0; fn[2]=1; while(scanf("%d",&n)!=EOF) { for(i=3;i<=n;i++) { fn[i]=(i-1)*(fn[i-2]+fn[i-1]); } printf("%lld\n",fn[n]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4568926.html