HDOJ 1398 Square Coins
Square Coins
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11690 Accepted Submission(s): 8007
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.
10
30
0
4
27
题意:
给出17种数字,分别为$i^{2}$,每种数字有无穷个可以选择,问有多少种方法可以组合出n...
分析:
生成函数的系数...
代码:
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
//by NeighThorn
using namespace std; const int maxn=300+5; int n,a[maxn],b[maxn],tmp[maxn]; signed main(void){
while(scanf("%d",&n)&&n){
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
b[0]=1;
for(int i=1;i<=17;i++){
memset(a,0,sizeof(a));
memset(tmp,0,sizeof(tmp));
for(int j=0;i*i*j<=n;j++)
tmp[i*i*j]=1;
for(int j=0;j<=n;j++)
if(b[j])
for(int k=0;k<=n;k++)
if(tmp[k])
a[j+k]+=b[j];
memcpy(b,a,sizeof(b));
}
printf("%d\n",b[n]);
}
return 0;
}
By NeighThorn
HDOJ 1398 Square Coins的更多相关文章
- HDOJ 1398 Square Coins 母函数
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 (母函数)
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)
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 ...
随机推荐
- [未完] term.js 记录遇到的问题
参考博文:https://www.cnblogs.com/zhenfei-jiang/p/7065038.html 按照网上查找的资料敲了代码 term.on('data', function(dat ...
- python字典形list 去重复
data_list = [{"}] run_function = lambda x, y: x if y in x else x + [y] return reduce(run_functi ...
- https://www.atlassian.com
https://www.atlassian.com 解决:confluence 5.9.4 一次性恢复30个插件 - 简书 https://www.jianshu.com/p/c32d8aa739b8 ...
- 千万不要错过这几道Python面试题,Python面试题No16
第1题: python下多线程的限制以及多进程中传递参数的方式? python多线程有个全局解释器锁(global interpreter lock),简称GIL,这个GIL并不是python的特性, ...
- But You Didn'd【但是你没有】
But You Didn't Remember the day I borrowed your brand new car and dented it? I thought you'd kill me ...
- Codeforces Round #464 (Div. 2) C. Convenient For Everybody
C. Convenient For Everybody time limit per test2 seconds memory limit per test256 megabytes Problem ...
- 笔记-python-build-in-types
笔记-python-build-in-types 注:文档内容来源为Python 3.6.5 documentation 1. built-in types 1.1. 真值测试 所有对 ...
- socketCluster 使用
<html> <head> <title>test</title> <script src="https://cdn.bootcss.c ...
- 设计模式之第8章-策略模式(Java实现)
设计模式之第8章-策略模式(Java实现) “年前大酬宾了啊,现在理发冲500送300,冲1000送500了.鱼哥赶紧充钱啊,理发这事基本一个月一回,挺实惠的啊.不过话说那个理发店的老板好傻啊,冲10 ...
- 【Trapping Rain Water】cpp
题目: Given n non-negative integers representing an elevation map where the width of each bar is 1, co ...