ACM乐园
Love Me,Love My Code!
posts - 53,  comments - 24,  trackbacks - 0
http://acm.hdu.edu.cn/showproblem.php?pid=1398

将增量存在数组中,这次有17个表达式相乘。
#include <iostream>

using namespace std;

const int M=301;
int table[18]={
    
0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289};//存储第i个表达式的增量
int a[M];
int b[M];


int main()
{
    
int i,j,k,n;
    
while(scanf("%d",&n)!=EOF,n)
    {
        
for(i=0;i<=n;i++)
        {
            a[i]
=1;
            b[i]
=0;
        }
        
for(i=2;i<=17;i++)//17个表达式
        {
            
for(j=0;j<=n;j++)
                
for(k=0;k+j<=n;k+=table[i])//增量为table[i]
                    b[k+j]+=a[j];
            
for(j=0;j<=n;j++)
            {
                a[j]
=b[j];
                b[j]
=0;
            }
        }
        printf(
"%d\n",a[n]);
    }
    
return 0;
}




posted on 2011-09-17 14:58 大大木马 阅读(237) 评论(0)  编辑 收藏 引用

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



<2011年9月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

常用链接

留言簿(1)

随笔档案(53)

文章档案(2)

搜索

  •  

积分与排名

  • 积分 - 62271
  • 排名 - 353

最新评论

阅读排行榜

评论排行榜