果的bell数,poj的G++编译器需要用%f输出double,%lf会WA
#include <stdio.h>
double num[110][110];
int n;
int main()
{
while (scanf("%d", &n), n)
{
int i, j;
double ans= 0;
num[0][0]=1;
for ( i = 1 ; i <= n; i++ )
{
num[i][0]=1;
for ( j = 1 ; j < i ; j++ )
num[i][j]=num[i-1][j-1]+ (j+1) * num[i-1][j];
num[i][i]= 1;
}
for ( i = 0 ; i < n ; i++ )
ans+=num[n-1][i];
printf("%d %.0f\n", n, ans);
}
return 0;
}