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 ...
随机推荐
- Finders Keepers-freecodecamp算法题目
Finders Keepers 1.要求 写一个 function,它遍历数组 arr,并返回数组中第一个满足 func 返回值的元素. 举个例子,如果 arr 为 [1, 2, 3],func 为 ...
- numpy学习(二)
ndarray的聚合操作 此博客讲的非常清楚,参照此博客即可 https://blog.csdn.net/qq_42571805/article/details/81146133
- Apache 配置默认编码
找到apache配置文件 httpd.conf ,找到以下内容 # # Specify a default charset for all content served; this enables # ...
- Java 技术栈
JAVA是一个面向对象的编程语言,由SUN公司的程序员所开发.它不仅吸收了C++的各种优点,而且还撇弃了C++中难以理解的概念,如多继承.指针等:因此JAVA语言具有功能强大且简单易用两个特征, JA ...
- DFS:Prime Ring Problem(素数环)
解体心得: 1.一个回溯法,可以参考八皇后问题. 2.题目要求按照字典序输出,其实在按照回溯法得到的答案是很正常的字典序.不用去特意排序. 3.输出有个坑,就是在输出一串的最后不能有空格,不然要PE, ...
- CF 497 div 2 B
B. Turn the Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- SSH无密码登录及远程拷贝命令SCP的使用
SSH无密码登录 1.生成密钥对(公钥和私钥) $ cd /home/cen/.ssh $ ssh-keygen -t rsa #生成密钥,使用rsa方式进行加密,四个回车 $ ssh-copy-id ...
- 4 Template层- HTML转义
1.HTML转义 Django对字符串进行自动HTML转义,如在模板中输出如下值: 视图代码: def index(request): return render(request, 'temtest/ ...
- luogu3195 [HNOI2008]玩具装箱TOY
懒得写 #include <iostream> #include <cstdio> using namespace std; typedef long long longliv ...
- 【Best Time to Buy and Sell Stock】cpp
题目: Say you have an array for which the ith element is the price of a given stock on day i. If you w ...