Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

此题不要高精,double 就可以,附代码

Posted by yzhw9981 at 2010-08-22 17:00:00 on Problem 1671
# include <iostream>
# include <cstdio>
# include <cstring>
using namespace std;
double dp[51][51];
double sum[51];
int main()
{
    memset(dp,0,sizeof(dp));
    dp[1][1]=1;
    sum[1]=1;
    for(int i=2;i<=50;i++)
    {
       sum[i]=0;
       for(int j=1;j<=i;j++)
       {
          dp[i][j]=j*dp[i-1][j]+dp[i-1][j-1];
          sum[i]+=dp[i][j];
       }
    }
    int n;
    while(true)
    {
       cin>>n;
       if(!n) break;
       printf("%d %.0f\n",n,sum[n]);
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator