1 2 0
1 1
#include<iostream> #include<algorithm> using namespace std; int main() { _int64 ls[30]={0,0,1}; _int64 gq[30]={1,1,2}; for(int i=3;i<26;i++) { ls[i]=(i-1)*(ls[i-1]+ls[i-2]); gq[i]=gq[i-1]*i; } int n; while(cin>>n,n) { _int64 sum=0; if(n==1||n==2||n==3) { cout<<1<<endl; continue; } for(int k=n/2;k>1;k--) sum+=gq[n]/(gq[k]*gq[n-k])*(ls[k]); printf("%I64d\n",sum+1); } return 0; }
原文地址:http://blog.csdn.net/lsgqjh/article/details/44967861