HDUOJ ------1398
http://acm.hdu.edu.cn/showproblem.php?pid=1398
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6697 Accepted Submission(s): 4521
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
Recommend
Ignatius.L
母函数.......
1 #include<iostream>
2 using namespace std;
3 int main()
4 {
5 int n,i,j,k;
6 while(cin>>n,n)
7 {
8 int c1[301]={0},c2[301]={0};
9 for(j=0;j<=n;j++)
10 {
11 c1[j]=1;
12 }
13 for(i=2;i*i<=n;i++)
14 {
15 for(j=0;j<=n;j++)
16 {
17 for(k=0;k+j<=n;k+=i*i)
18 {
19 c2[k+j]+=c1[j];
20 }
21 }
22 for(j=0;j<=n;j++)
23 {
24 c1[j]=c2[j];
25 c2[j]=0;
26 }
27 }
28 cout<<c1[n]<<endl;
29 }
30 return 0;
31 }
- 不给“爸爸”添麻烦 - iTOP iOS 动态库改造
- 移动SEO分享:php自动提交复合型Sitemap到百度搜索
- 《Android外部存储》
- Android JNI出坑指南
- 《iPhone X ARKit Face Tracking》
- 结合标签广告,定制一个QQ邮箱订阅
- SecureCRT全局发送相同命令,快速抓取服务器信息的方法
- [不定期更新]简单的shell脚本练习实例
- 超简单的MySQL主从复制配置步骤
- 解决Centos下vsftp无法上传文件的问题,附vsftp配置详解
- 为iFrame添加动态载入效果,提高用户体验
- 分享超炫的表白页面和爱的纪念日源码
- 分享WordPress Mobile Pack汉化精简版及隐藏指定插件更新提示的方法
- Tomcat重启脚本For Windows
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- webpack实战——生产环境配置【下】
- R语言作图——Violin plot with dot
- AkShare-中国宏观-全社会用电分类情况表
- Angular应用从Component到Html的数据绑定是如何实现的
- 3分钟短文:Laravel Form,让你不再写 HTML 的好“库”
- Angular应用input和div标签页的动态创建场景
- 在Angular的index.html里插入script,拦截所有动态创建标签页的场景
- Angular应用里input字段后面的_ngcontent-hqi是什么含义
- WPF 已知问题 窗口在屏幕外创建将不会刷新渲染
- NuGet 更新库新版本的缓存问题
- 在Java项目中打印错误日志的正确姿势,排查问题更方便,非常实用!
- 开源后台系统*mee-admin*
- stc89c52在Linux或MacOS下使用sdcc和stcgal中断与LCD测试代码
- 豆瓣9.2分!17万条弹幕告诉你《沉默的真相》凭什么口碑高开暴走!
- Shader 入门:GLSL ES(迭代、选择和跳转)