Square Coins

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

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
 
 
dp的完全是按照hdu1028的改的,套那个的感觉。
初始化要比1028难一点,不光要所有的都弄成1,因为这次的不是连续的,所有有的就没有递归上,但是后面的数不可能比前面的小,所以每次都加上一个 d[i][i]=d[i][a[j]];
#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)的更多相关文章

  1. hdu 1398 Square Coins (母函数)

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  2. 题解报告:hdu 1398 Square Coins(母函数或dp)

    Problem Description People in Silverland use square coins. Not only they have square shapes but also ...

  3. hdu 1398 Square Coins(简单dp)

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Pro ...

  4. HDU 1398 Square Coins 整数拆分变形 母函数

    欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit ...

  5. HDU 1398 Square Coins(DP)

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  6. hdu 1398 Square Coins 分钱币问题

    Square Coins Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

  7. hdu 1398 Square Coins(生成函数,完全背包)

    pid=1398">链接:hdu 1398 题意:有17种货币,面额分别为i*i(1<=i<=17),都为无限张. 给定一个值n(n<=300),求用上述货币能使价值 ...

  8. HDOJ 1398 Square Coins 母函数

    Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  9. 杭电ACM hdu 1398 Square Coins

    Problem Description People in Silverland use square coins. Not only they have square shapes but also ...

随机推荐

  1. c#中的String方法

    1.Replace(替换字符):public string Replace(char oldChar,char newChar);在对象中寻找oldChar,如果寻找到,就用newChar将oldCh ...

  2. PHP 页面跳转的三种方式

    第一种方式:header() header()函数的主要功能是将HTTP协议标头(header)输出到浏览器. 语法: void header ( string $string [, bool $re ...

  3. sql语句中的join连接(左连接、右连接、全连接、内连接)

    内部连接(inner join): select * from d_user a inner join D_ORGANIZATION b on a.COMPANY_XID=b.ID  内部链接也是排他 ...

  4. POJ-2594 Treasure Exploration,floyd+最小路径覆盖!

                                                 Treasure Exploration 复见此题,时隔久远,已忘,悲矣! 题意:用最少的机器人沿单向边走完( ...

  5. cell展开的几种方式

    一.插入新的cell 原理: (1)定义是否展开,和展开的cell的下标 @property (assign, nonatomic) BOOL isExpand; //是否展开 @property ( ...

  6. 有大神告诉我为什么pymysql导入失败

    import json import requests import pymysql url = 'https://xueqiu.com/v4/statuses/public_timeline_by_ ...

  7. bzoj1411: [ZJOI2009]硬币游戏

    1411: [ZJOI2009]硬币游戏 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 965  Solved: 420[Submit][Status ...

  8. PHP中使用GD库方式画时钟

    <!--demo.html中内容--> <body> <img id="time" src="test.php" /> &l ...

  9. Goldbach

    Description: Goldbach's conjecture is one of the oldest and best-known unsolved problems in number t ...

  10. Spring入门之setter DI注入

    1.新建Java项目导入依赖jar包,参考前一章 2.以不同文件格式输出为例 3.定义接口IOutputGenerator.java package com.spring.output; public ...