xfstart07
Get busy living or get busy dying

#include < iostream >
using   namespace  std;

int  n;
int  f[ 3010 ][ 65 ] = { 0 };
int  l;
int  tmp[ 65 ];
void  mul( int  a, int  b){
    memset(tmp,
0 , sizeof (tmp));
    tmp[
0 ] = f[a][ 0 ];
    
for ( int  i = 1 ;i <= tmp[ 0 ]; ++ i)
        tmp[i]
= f[a][i] * b;
    
for ( int  i = 1 ;i <= tmp[ 0 ]; ++ i){
        tmp[i
+ 1 ] += tmp[i] / 100000000 ;
        tmp[i]
%= 100000000 ;
    }
    
while (tmp[tmp[ 0 ] + 1 ]){
        tmp[
0 ] ++ ;
        tmp[tmp[
0 ] + 1 ] += tmp[tmp[ 0 ]] / 100000000 ;
        tmp[tmp[
0 ]] %= 100000000 ;
    }
}
bool  max( int  a[]){
    
if (tmp[ 0 ] > a[ 0 ])  return   1 ;
    
else   if (a[ 0 ] > tmp[ 0 ])  return   0 ;
    
else   for ( int  i = a[ 0 ];i >= 1 ; -- i)
        
if (tmp[i] > a[i])  return   1 ;
        
else   if (tmp[i] < a[i])  return   0 ;
    
return   0 ;
}
int  main()
{
    scanf(
" %d " , & n);
    f[
0 ][ 0 ] = 1 ; f[ 0 ][ 1 ] = 1 ;
    
for ( int  i = 1 ;i <= n; ++ i)
        f[i][
0 ] = 1 ;
    
for ( int  i = 1 ;i <= n; ++ i)
        
for ( int  j = i;j <= n; ++ j){
            mul(j
- i,i);
            
if (max(f[j])){
                
for ( int  i = 0 ;i <= tmp[ 0 ]; ++ i)
                    f[j][i]
= tmp[i];
            }
        }
    
// cout<<f[n][0]<<endl;
    printf( " %d " ,f[n][f[n][ 0 ]]);
    
for ( int  i = f[n][ 0 ] - 1 ;i >= 1 ; -- i)
        printf(
" %08d " ,f[n][i]);
    printf(
" \n " );
    
return   0 ;
}




posted on 2009-06-03 23:17 xfstart07 阅读(190) 评论(0)  编辑 收藏 引用 所属分类: 代码库

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理