Square Coins

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7605    Accepted Submission(s): 5151

Problem Description
People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values of all square numbers up to 289 (=17^2), i.e., 1-credit coins, 4-credit coins, 9-credit coins, ..., and 289-credit coins, are available in Silverland.
There are four combinations of coins to pay ten credits:

ten 1-credit coins,
one 4-credit coin and six 1-credit coins,
two 4-credit coins and two 1-credit coins, and
one 9-credit coin and one 1-credit coin.

Your mission is to count the number of ways to pay a given amount using coins of Silverland.

 
Input
The input consists of lines each containing an integer meaning an amount to be paid, followed by a line containing a zero. You may assume that all the amounts are positive and less than 300.
 
Output
For each of the given amount, one line containing a single integer representing the number of combinations of coins should be output. No other characters should appear in the output.
 
Sample Input
2 10 30 0
 
Sample Output
1 4 27
 
Source
 
 #include <stdio.h>
int main()
{
int i,j,k,n;
int c1[],c2[];
while(scanf("%d",&n),n)
{
for(i=;i<=n;i++)
{
c1[i]=;
c2[i]=;
}
for(i=;i<=n;i++)
{
for(j=;j<=n;j++)
for(k=;k+j<=n;k+=i*i)
{
c2[k+j]+=c1[j];
}
for(j=;j<=n;j++)
{
c1[j]=c2[j];
c2[j]=;
}
}
printf("%d\n",c1[n]);
}
return ;
}

最新文章

  1. IP地址,子网掩码、默认网关,DNS服务器是什么意思?
  2. Struts2中动态方法的调用
  3. 利用PHP取二进制文件头判断文件类型
  4. Linux下安装Apache并以mod_wsgi方式部署django站点
  5. SVG 基础
  6. 第 30 章 使用 Emmet 插件
  7. EasyUi 改变 selelct 的 下拉内容 div 的高度
  8. PS网页设计教程XXX——在PS中创建一个漫画书主题网页布局
  9. java演示facade(外观)模式
  10. Windows程序设计 贪吃蛇c
  11. STL的移动算法
  12. C#利用UdpClient发送广播消息
  13. Django使用Celery异步任务队列
  14. springMVC2
  15. 杭电ACM2009--求数列的和
  16. Tomcat服务器下载、安装、配置环境变量教程(超详细)
  17. maven项目pom.xml添加main启动类
  18. Python—函数的名称空间
  19. RESTful API实战笔记(接口设计及Java后端实现)
  20. SQLSERVER 导出表数据为insert 语句

热门文章

  1. [转][ASP.NET MVC]如何定制Numeric属性/字段验证消息
  2. PHP使用Session遇到的一个Permission denied Notice解决办法
  3. 微信“摇一摇&amp;#183;周边”正式开放
  4. php中读取以及写入文件的方法总结
  5. Objective -C Object initialization 对象初始化
  6. 使用Jenkins进行android项目的自动构建(2)
  7. bat批处理如何删除本地策略里的用户权限分配中的拒绝从网络访问本机项的guest用户?
  8. cookie设置和读取以及获取超链接参数
  9. 获取url上的参数
  10. rem怎么算