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 ;
}

hdu_1398_Square Coins_201404260953的更多相关文章

随机推荐

  1. Jquery操作常用表单元素

    由于对前端的东西不是很熟练,导致jquery操作表单的东西总是忘记,每次用都要查一下,效率低下,记录下来,以便下次使用. CheckBox checkbox改变事件 $('#IsAllSearch') ...

  2. 组合模式和php实现

    组合模式(有时候又叫做部分-整体模式): 将对象组合成树形结构以表示“部分整体”的层次结构.组合模式使得用户对单个对象和组合对象的使用具有一致性.它使我们树型结构的问题中,模糊了简单元素和复杂元素的概 ...

  3. Django model 反向引用中的related_name

    转自:https://blog.csdn.net/lanyang123456/article/details/68962515 问题: 定义表Apple: class Apple( models.Mo ...

  4. 支付宝SDK

    由于支付宝SDK对于整个支付流程已经介绍的十分详细了,在这里我就简单说一些注意点. 由于存在支付宝可能没有安装的情况,所以我们在调用支付宝支付时,需要对其进行判断,做出不同的处理方式,即是使用客户端支 ...

  5. Maven error in eclipse (pom.xml) : Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4

    i wanna make web project using the Maven to import automatically all libraries that i need, so i cho ...

  6. (转)淘淘商城系列——使用maven tomcat插件启动web工程

    http://blog.csdn.net/yerenyuan_pku/article/details/72672138 上文我们一起学习了怎样搭建maven工程,这篇文章我就来教大家一起学习怎样用to ...

  7. 火狐加载用户配置文件 "C:\XXX\Mozilla Firefox\firefox.exe" http://192.168.1.1:8080 -profile ../kkk

    "C:\XXX\Mozilla Firefox\firefox.exe" http://192.168.1.1:8080 -profile ../kkk $("#clic ...

  8. width:100px; min-width:100% 解释:宽度大于100px 就是100% 小于100px 就是100像素

    <div style="width:100px; background-color: aqua; min-width:100%">kkk</div>

  9. 纯CSS3来自定义单选框radio与复选框checkbox

    单选框(radio)自定义样式 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 ...

  10. 关于Maven项目的pom.xml中的依赖或插件失效的解决方法

    1.请将<dependency>标签包含的依赖从<dependencyManagement>中拿出来,单独放在<dependencies>标签里面.2.请将< ...