hdu 1465

来源:互联网 发布:电信宽带发现代理软件 编辑:程序博客网 时间:2024/05/23 21:30

不容易系列之一

http://acm.hdu.edu.cn/showproblem.php?pid=1465
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
    long long int a[21];
    int i,n;
    while(cin>>n)
    {
    a[1]=0;
    a[2]=1;
    a[3]=2;
    for(i=4;i<=n;i++)
    a[i]=(i-1)*(a[i-1]+a[i-2]);
    cout<<a[n]<<endl;
    }
    return 0;
}

这是一道简单的错排问题,关于这方面的问题,详情看下网站

http://user.qzone.qq.com/1153672901/infocenter?ptlang=2052&ADUIN=1153672901&ADSESSION=1276563907&ADTAG=CLIENT.QQ.2839_Mysrv.0

本人的QQ空间

原创粉丝点击