HDU 1398 Square Coins(母函数或dp)
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9903 Accepted Submission(s): 6789
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 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.
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.
10
30
0
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 333
int a[],n,d[N][N]; int main()
{
for(int i=;i<=;i++)
a[i]=i*i;
for(int i=;i<=;i++)
for(int j=;j<=;j++)
d[i][j]=; for(int i=;i<=;i++)
{
for(int j=;j<=&&a[j]<=i;j++)
{
d[i][a[j]]=d[i][a[j-]]+d[i-a[j]][min(a[j],i-a[j])];
d[i][i]=d[i][a[j]];
}
}
int i;
while(cin>>i&&i)
{
cout<<d[i][a[(int)sqrt(i)] ]<<endl;
}
return ;
}
HDU 1398 Square Coins(母函数或dp)的更多相关文章
- 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)
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
- hdu 1398 Square Coins(简单dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Pro ...
- HDU 1398 Square Coins 整数拆分变形 母函数
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit ...
- HDU 1398 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:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- hdu 1398 Square Coins(生成函数,完全背包)
pid=1398">链接:hdu 1398 题意:有17种货币,面额分别为i*i(1<=i<=17),都为无限张. 给定一个值n(n<=300),求用上述货币能使价值 ...
- HDOJ 1398 Square Coins 母函数
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- 杭电ACM hdu 1398 Square Coins
Problem Description People in Silverland use square coins. Not only they have square shapes but also ...
随机推荐
- c#中的String方法
1.Replace(替换字符):public string Replace(char oldChar,char newChar);在对象中寻找oldChar,如果寻找到,就用newChar将oldCh ...
- PHP 页面跳转的三种方式
第一种方式:header() header()函数的主要功能是将HTTP协议标头(header)输出到浏览器. 语法: void header ( string $string [, bool $re ...
- sql语句中的join连接(左连接、右连接、全连接、内连接)
内部连接(inner join): select * from d_user a inner join D_ORGANIZATION b on a.COMPANY_XID=b.ID 内部链接也是排他 ...
- POJ-2594 Treasure Exploration,floyd+最小路径覆盖!
Treasure Exploration 复见此题,时隔久远,已忘,悲矣! 题意:用最少的机器人沿单向边走完( ...
- cell展开的几种方式
一.插入新的cell 原理: (1)定义是否展开,和展开的cell的下标 @property (assign, nonatomic) BOOL isExpand; //是否展开 @property ( ...
- 有大神告诉我为什么pymysql导入失败
import json import requests import pymysql url = 'https://xueqiu.com/v4/statuses/public_timeline_by_ ...
- bzoj1411: [ZJOI2009]硬币游戏
1411: [ZJOI2009]硬币游戏 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 965 Solved: 420[Submit][Status ...
- PHP中使用GD库方式画时钟
<!--demo.html中内容--> <body> <img id="time" src="test.php" /> &l ...
- Goldbach
Description: Goldbach's conjecture is one of the oldest and best-known unsolved problems in number t ...
- Spring入门之setter DI注入
1.新建Java项目导入依赖jar包,参考前一章 2.以不同文件格式输出为例 3.定义接口IOutputGenerator.java package com.spring.output; public ...