题意: 有17种硬币,每种的面值为编号的平方,比如 1,4,9,16.....给出一个数字,求组成这个面值有多少种组法? 思路: 用普通母函数解,主要做的就是模拟乘法,因为硬币是无限的,所以每个构造式中每一个项的系数都是1.我们只需要第n项的系数,大于n的并不需要,所以大于n的项就不用再做计算了. #include <bits/stdc++.h> using namespace std; ; int main() { freopen("input.txt", "r…
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9728    Accepted Submission(s): 6668 Problem Description People in Silverland use square coins. Not…
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, ...…
Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7883    Accepted Submission(s): 5332 Problem Description People in Silverland use square coins. Not only they have square shapes but…
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…
Square Coins Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1398 Description People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Co…
Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description People in Silverland use square coins. Not only they have square shapes but also their values are square numbers. Coins with values o…
pid=1398">链接:hdu 1398 题意:有17种货币,面额分别为i*i(1<=i<=17),都为无限张. 给定一个值n(n<=300),求用上述货币能使价值总和为n的方案数 分析:这题能够用母函数的思想,对300以内的值进行预处理就可以 也可用全然背包思想求300以内的方案数 母函数: #include<stdio.h> int main() { int c1[305],c2[305],i,j,k,n; for(i=0;i<=300;i++){…
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, ...…
Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8800    Accepted Submission(s): 5991 Problem Description People in Silverland use square coins. Not only they have square shapes but…
题目大意:有面值分别为.1,4,9,.......17^2的硬币无数多个.问你组成面值为n的钱的方法数. 最简单的母函数模板题: #include <cstdio> #include <cstring> using namespace std; int c1[305],c2[305],n; int main(){ while(scanf("%d",&n),n){ for(int i=0;i<=n;i++)c1[i]=1,c2[i]=0; for(i…
预处理出完全平方数就和普通的生成函数解整数拆分一样了 #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…
Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6416    Accepted Submission(s): 4336 Problem Description People in Silverland use square coins. Not only they have square shapes but…
Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11690    Accepted Submission(s): 8007 Problem Description People in Silverland use square coins. Not only they have square shapes but…
Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11529    Accepted Submission(s): 7897 Problem Description People in Silverland use square coins. Not only they have square shapes but…
Square Coins 点我 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-c…
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 28…
Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15764    Accepted Submission(s): 10843 Problem Description People in Silverland use square coins. Not only they have square shapes bu…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13791    Accepted Submission(s): 9493 Problem Description People in Silverland use square coins. Not only they have square shapes but also their v…
Square Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6746    Accepted Submission(s): 4554 Problem DescriptionPeople in Silverland use square coins. Not only they have square shapes but a…
HDOJ(HDU).3466 Dividing coins ( DP 01背包 无后效性的理解) 题意分析 要先排序,在做01背包,否则不满足无后效性,为什么呢? 等我理解了再补上. 代码总览 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define nmax 505 #define nn 505*100 using namespace std;…
题意:输入一个n  给出其所有组合数 如: 4 = 4;  4 = 3 + 1;  4 = 2 + 2;  4 = 2 + 1 + 1;  4 = 1 + 1 + 1 + 1; 重复不算 母函数入门题: #include<iostream> #include<queue> #include<cstdio> #include<cstring> #include<vector> #include<map> #include<algo…
有1,4,9,16,25.....2^17这么多面值的硬币,问任意给定一个不大于300的正整数面额,用这些硬币来组成此面额总共有多少种组合种数 比如10全14 + 6个 14+4+1+19+1 求(1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9+x^10)(1+x^4+x^8)(1+x^9)中x^10的系数即可 只是把模板的 i<=n改成了i*i<=n,在k遍历指数时把k=k+i变成了k=k+i*i Sample Input210300 Sample Output142…
题目类似于整数拆分,很明显用母函数来做. 母函数的写法基本固定,根据具体每项乘式的不同做出一些修改就行了.它的思路是从第一个括号开始,一个括号一个括号的乘开,用c1数组保存之前已经乘开的系数,即c1[j]表示在之前已经乘开过的那些括号处理后x的j次方的系数,c2数组是一个临时更新的统计数组,每处理一个括号就更新一遍c1数组即可. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstri…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1398 看到网上的题解都是说母函数……为什么我觉得就是一个dp就好了,dp[i][j]表示只用前i种硬币,组成价值为j的价格的方案数,转移枚举第i种硬币用多少个就好了. #include<bits/stdc++.h> using namespace std; ; ][maxn]; int main() { ;i<=;i++) { ;j<=;j++) { // i*i coin dp[i]…
Lucky Coins 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5985 Description Bob has collected a lot of coins in different kinds. He wants to know which kind of coins is lucky. He finds out a lucky kind of coins by the following way. He tosses all th…
You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number of full staircase rows that can be formed. n is a non-negative integer and fits within the range of…
Big Event in HDU  HDU1171 就是求一个简单的背包: 题意:就是给出一系列数,求把他们尽可能分成均匀的两堆 如:2 10 1 20 1     结果是:20 10.才最均匀! 三种解法: 多重背包的优化与否:(1031MS) #include<iostream> #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; ]; ],b[];…
Given a non-negative integer c, your task is to decide whether there're two integers a and b such that a2 + b2 = c. Example 1: Input: 5 Output: True Explanation: 1 * 1 + 2 * 2 = 5 Example 2: Input: 3 Output: False 这道题让我们求一个数是否能由平方数之和组成,刚开始博主没仔细看题,没有看…
http://acm.split.hdu.edu.cn/showproblem.php?pid=5985 题意:有多种类型的硬币,每种类型的硬币都有一定的数量,现在每次抛硬币,除去朝下的硬币,知道最后只剩下一个硬币或者没有硬币,最后的硬币便是幸运硬币,求每种类型硬币成为幸运硬币的概率. 思路: 硬币的概率都是单独的,所以我们只需要计算一个硬币的概率情况即可. 设die[i][k]表示第i种硬币在第k次全部被抛弃的概率,易得,用alive[i][k]表示第i种硬币在第k次至少有一个存活的概率就是$…