Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17917    Accepted Submission(s): 12558 Problem Description "Well, it seems the first problem is too easy. I will let…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 题意: 给你一个正整数n,将n拆分成若干个正整数之和,问你有多少种方案. 注:"4 = 3 + 1"和"4 = 1 + 3"视为同一种方案.(加数是无序的) 题解1(dp): 表示状态: dp[n][m] = num of methods 表示用均不超过m的元素组成n的方法数. 如何转移: 假设当前状态为dp[n][m]. 对于等于m的元素,有两种决策.要么不用,…
题目链接:hdu 1028 Ignatius and the Princess III 题意:对于给定的n,问有多少种组成方式 思路:dp[i][j],i表示要求的数,j表示组成i的最大值,最后答案是dp[i][i].那么dp[i][j]=dp[i][j-1]+dp[i-j][i-j],dp[i][j-1]是累加1到j-1的结果,dp[i-j][i-j]表示的就是最大为j,然后i-j有多少种表达方式啦.因为i-j可能大于j,这与我们定义的j为最大值矛盾,所以要去掉大于j的那些值 /*******…
此题无法用JavaAC,不相信的可以去HD1029题试下! Problem Description "OK, you are not too bad, em- But you can never pass the next test." feng5166 says. "I will tell you an odd number N, and then N integers. There will be a special integer among them, you hav…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 16028    Accepted Submission(s): 11302 Problem Description "Well, it seems the first problem is too easy. I will let…
题目信息:求分解整数n的个数q(n);能够母函数或者DP http://acm.hdu.edu.cn/showproblem.php?pid=1028 AC代码: /****************************** 题目大意:求分解整数n的个数q(n) 例: 5 = 5; 5 = 4 + 1; 5 = 3 + 1 + 1; 5 = 3 + 2; 5 = 2 + 2 + 1; 5 = 2 + 1 + 1 + 1; 5 = 1 + 1 + 1 + 1 + 1; sum(5) = 7;不区…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24975    Accepted Submission(s): 17253 Problem Description "Well, it seems the first problem is too easy. I will let…
 Ignatius and the Princess III Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says.  "Th…
http://acm.hdu.edu.cn/showproblem.php?pid=1028 母函数: 例1:若有1克.2克.3克.4克的砝码各一 枚,能称出哪几种重量?各有几种可能方案? 如何解决这个问题呢?考虑构造母函数.如果用x的指数表示称出的重量,则:    1个1克的砝码可以用函数1+x表示,    1个2克的砝码可以用函数1+x2表示,    1个3克的砝码可以用函数1+x3表示,    1个4克的砝码可以用函数1+x4表示, (1+x)(1+x2)(1+x3)(1+x4)=(1+x…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1028 思路分析:该问题要求求出某个整数能够被划分为多少个整数之和(如 4 = 2 + 2, 4 = 2 + 1 + 1),且划分的序列 2, 2 或者 2, 1, 1为单调非递增序列: 使用动态规划解法:假设dp[i][j]表示整数i被划分的序列中最大值不超过j的所有的可能,则使用类似于0-1背包的思考方法: (1)如果i == j,则dp[i][j] = dp[i][j-1] + 1: (2)如果…
这个题也能够用递归加记忆化搜索来A,只是因为这题比較简单,所以用来做母函数的入门题比較合适 以展开后的x4为例,其系数为4,即4拆分成1.2.3之和的拆分数为4: 即 :4=1+1+1+1=1+1+2=1+3=2+2 这里再引出两个概念整数拆分和拆分数: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <climits> #in…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 11783    Accepted Submission(s): 8343 Problem Description "Well, it seems the first problem is too easy. I will let…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25929    Accepted Submission(s): 17918 Problem Description "Well, it seems the first problem is too easy. I will let…
链接: https://vjudge.net/problem/HDU-1028 题意: "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says. "The second problem is, given an positive integer N, we define an equation like this:…
方法一:    直接进行排序,输出第(n+1)/2位置上的数即可. (容易超时,关闭同步后勉强卡过) #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; int n; ]; int main() { ios::sync_with_stdio(false); while(cin&g…
母函数介绍见另一篇随笔HDU1028Ignatius and the Princess III(母函数) #include<iostream> #include<stdio.h> #include<string.h> #include<map> #include<vector> #include<set> #include<stack> #include<queue> #include<algorithm…
母函数的简单应用http://acm.hdu.edu.cn/showproblem.php?pid=2079 介绍见另一篇随笔HDU1028Ignatius and the Princess III(母函数) #include<stdio.h> int main() { int T; while(~scanf("%d", &T))while(T--) { ]={},c2[]={}; int num,val; int i,n,k; scanf("%d%d&q…
1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood Species POJ 2418D - StationE - Web Navigation ZOJ 1061F - Argus ZOJ 2212G - Plug-in2.SegmentTreeA-敌兵布阵 hdu 1166B - I Hate It HDU 1754C - A Simple Pro…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15942    Accepted Submission(s): 11245 Problem Description "Well, it seems the first problem is too easy. I will let…
Problem Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says."The second problem is, given an positive integer N, we define an equation like this:  N=a[1]+a[2]+a[3]+...+a[m…
Ignatius and the Princess III HDU - 1028 整数划分问题 假的dp(复杂度不对) #include<cstdio> #include<cstring> typedef long long LL; LL ans[][]; LL n,anss; LL get(LL x,LL y) { ) return ans[x][y]; ) ; ; ans[x][y]=; LL i; ;i<=y;i++) ans[x][y]+=get(x-y,i); re…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says. &…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 20918    Accepted Submission(s): 14599 Problem Description "Well, it seems the first problem is too easy. I will let…
钱币兑换问题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5069    Accepted Submission(s): 2868 Problem Description 在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法.请你编程序计算出共有多少种兑法.   Input 每行只有一个正整数N,N小于32768.   O…
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25805    Accepted Submission(s): 17839 Problem Description "Well, it seems the first problem is too easy. I will let…
Time limit per test: 2.0 seconds Memory limit: 512 megabytes 唐纳德先生的某女性朋友最近与唐纳德先生同居.该女性朋友携带一 baby.该 baby 酷爱吃棒棒糖,且有一个奇怪的特性:今天吃的棒棒糖一定要比昨天的棒棒糖更多,至少要一样多.如果棒棒糖少了,baby 就会很不高兴:另外如果有连续 k 天棒棒糖的数量都是一样的,baby 也会很不高兴. 唐纳德先生发现他的口袋里只有可怜的 n 元钱,他可以用 1 元钱买 1 根棒棒糖.他想用这些…
时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 What is possibility of rolling N dice and the sum of the numbers equals to M? 输入 Two integers N and M. (1 ≤ N ≤ 100, 1 ≤ M ≤ 600) 输出 Output the possibility in percentage with 2 decimal places. 样例输入 2 10 样例输出 8.3…
题意: 输入一个数n,求组合成此数字可以有多少种方法,每一方法是不记录排列顺序的.用来组成的数字可以有1.2.3....n.比如n个1组成了n,一个n也组成n.这就算两种.1=1,2=1+1=2,3=3=1+2=1+1+1,而1+2和2+1只能算一种.n最大为120. 思路:关于母函数的原理不讲了.讲怎么实现几个括号相乘. 思路: 我们要算的n是等于120,把其简化为5,就是说设n最大为5,道理一样的.5一共有7种方法对吗!自己手写吧. 如果想要得出结果,那么一共有5个括号要相乘,分别如下: 为…
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…
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, ...…