Square Coins[HDU1398]
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6746 Accepted Submission(s): 4554
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
Asia 1999, Kyoto (Japan)
Recommend
Ignatius.L
#include<stdio.h>
#include<string.h>
int p[],tmp[];
void prepare()
{
int i,j,k;
for (i=;i<=;i++) p[i]=;
for (i=;i<=;i++)
{
memset(tmp,,sizeof(tmp));
for (j=;j<=;j++)
for (k=;k<=;k+=i*i)
tmp[j+k]+=p[j];
for (j=;j<=;j++) p[j]=tmp[j];
}
}
int main()
{
prepare();
int n;
while (scanf("%d",&n)!=EOF)
{
if (n==) return ;
printf("%d\n",p[n]);
}
return ;
}
Square Coins[HDU1398]的更多相关文章
- HDU1398 Square Coins(生成函数)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- HDU1398 Square Coins
Description People in Silverland use square coins. Not only they have square shapes but also their v ...
- HDU1398:Square Coins(DP水题)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu 1398 Square Coins (母函数)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- hdu 1398 Square Coins(简单dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Pro ...
- HDOJ 1398 Square Coins 母函数
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- Square Coins(母函数)
Square Coins 点我 Problem Description People in Silverland use square coins. Not only they have square ...
- HDU 1398 Square Coins 整数拆分变形 母函数
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit ...
- 杭电ACM hdu 1398 Square Coins
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
随机推荐
- ReactiveCocoa入门教程:第一部分
http://www.cocoachina.com/ios/20150123/10994.html 本文翻译自RayWenderlich,原文:ReactiveCocoa Tutorial--The ...
- (转)搞ACM的你伤不起
劳资六年前开始搞ACM啊!!!!!!!!!! 从此踏上了尼玛不归路啊!!!!!!!!!!!! 谁特么跟劳资讲算法是程序设计的核心啊!!!!!! 尼玛除了面试题就没见过用算法的地方啊!!!!!! 谁再跟 ...
- Linux SUID SGID 讲解
SUID属性 UNIX的内核是根据什么来确定一个进程对资源的访问权限的呢? 是这个进程的运行用户的(有效)ID,包括user id和group id.用户可以用id命令来查到自己的或其他用户的user ...
- Android自定义Dialog
Android开发过程中,常常会遇到一些需求场景——在界面上弹出一个弹框,对用户进行提醒并让用户进行某些选择性的操作, 如退出登录时的弹窗,让用户选择“退出”还是“取消”等操作. Android系统提 ...
- Moebius集群:SQL Server一站式数据平台
一.Moebius集群的架构及原理 1.无共享磁盘架构 Moebius集群采用无共享磁盘架构设计,各个机器可以不连接一个共享的设备,数据可以存储在每个机器自己的存储介质中.这样每个机器就不需要硬件上的 ...
- 【Linux】/dev/null 2>&1 详解
今天一个朋友突然在自己的维护的Linux中, /var/spool/cron/root 中看到了以下的内容: 30 19 * * * /usr/bin/**dcon.sh > /dev/nul ...
- TCP/IP WebSocket MQTT
http://www.cnblogs.com/shanyou/p/4085802.html TCP/IP, WebSocket 和 MQTT
- 1.1 让CPU占用率曲线听你指挥[cpu manager]
[本文链接] http://www.cnblogs.com/hellogiser/p/cpu-manager.html [题目] 写一个程序,让用户来决定Windows任务管理器(Task Manag ...
- GPL协议的MySQL数据库
网络上多数朋友担心甲骨文会对MySQL软件采用收费模式,多数朋友也不清楚MySQL开源到底是什么模式,开源=免费嘛?是很多的疑问?MySQL是遵守双重协议的,一个是GPL授权协议,一个是商用授权协议( ...
- window.open()读取本地图片简单使用总结
最近做了一个项目,需要读取本地图片出来,问了一些人,感觉在数据库中存取路径比较合适,故做此方法. 后台查询出来的路径