hdu 1398 Square Coins【生成函数】
预处理出完全平方数就和普通的生成函数解整数拆分一样了
#include<iostream>
#include<cstdio>
using namespace std;
const int N=605;
int n,m,q[N],a[N],b[N];
int main()
{
for(int i=1;i<=18;i++)
q[i]=i*i;
while(scanf("%d",&m)&&m)
{
for(n=1;q[n+1]<=m;n++);
for(int i=0;i<=m;i++)
a[i]=1,b[i]=0;
for(int i=2;i<=n;i++)
{
for(int j=0;j<=m;j++)
for(int k=0;k<=m;k+=q[i])
b[j+k]+=a[j];
for(int j=0;j<=m;j++)
a[j]=b[j],b[j]=0;
}
printf("%d\n",a[m]);
}
return 0;
}
hdu 1398 Square Coins【生成函数】的更多相关文章
- hdu 1398 Square Coins(生成函数,完全背包)
pid=1398">链接:hdu 1398 题意:有17种货币,面额分别为i*i(1<=i<=17),都为无限张. 给定一个值n(n<=300),求用上述货币能使价值 ...
- hdu 1398 Square Coins 分钱币问题
Square Coins Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- 题解报告: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 (母函数)
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 ...
- 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 ...
- 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(DP)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
随机推荐
- android存储訪问框架Storage Access Framework
在了解storage access framework之前.我们先来看看android4.4中的一个特性.假设我们希望能选择android手机中的一张图片,通常都是发送一个Intent给对应的程序.一 ...
- Raw-OS源代码分析之消息系统-Queue_Buffer
分析的内核版本号截止到2014-04-15,基于1.05正式版.blogs会及时跟进最新版本号的内核开发进度,若源代码凝视出现"???"字样,则是未深究理解部分. Raw-OS官方 ...
- HDU1114 Piggy-Bank 【全然背包】
Piggy-Bank Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- Desktop Management Interface & System Management BIOS
http://en.wikipedia.org/wiki/Desktop_Management_Interface Desktop Management Interface From Wikipedi ...
- openwrt: patch-dtb
dts的概念是linux kernel中的,跟openwrt的关系不大.只是恰好在学习openwrt的时候碰到了这个东西,所以记录在openwrt名下. patch-dtb openwrt对arch/ ...
- WebService:JAX-WS实现WebService
WebService和Java核心技术中的RMI一样用于实现异构平台上的应用程序之间数据的交互,唯一不同的是这样的技术屏蔽了语言之间的差异.这也是其大行其道的原因. 实现WebService的技术多种 ...
- Finally语句块的运行
一.finally语句块是否一定运行? Java中异常捕获机制try...catch...finally块中的finally语句是不是一定会被运行?非常多人都说不是.当然他们的回答是正确的,经过试验. ...
- 理解yarn平台,理解万岁,肤浅理解也万岁~
从Hadoop1到Hadoop2很大程度上解放了Jobtracker资源调度的问题,这就得多亏了yarn平台了.我知道的,除了我们的大豆瓣用的是Mesos,咱们国家可以说应该是99.99%都使用的是y ...
- queue_action
http://www.learn4master.com/programming-language/python/python-queue-for-multithreading
- Linux 进程等待队列【转】
本文转载自:http://blog.csdn.net/dlutbrucezhang/article/details/9212067 Linux内核的等待队列是以双循环链表为基础数据结构,与进程调度机制 ...