hdu 1398 Square Coins(简单dp)】的更多相关文章

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…
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): 9903    Accepted Submission(s): 6789 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): 8800    Accepted Submission(s): 5991 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)Total Submission(s): 7883    Accepted Submission(s): 5332 Problem Description People in Silverland use square coins. Not only they have square shapes but…
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++){…
欢迎参加——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, ...…
题目大意:有面值分别为.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…
题意: 有17种硬币,每种的面值为编号的平方,比如 1,4,9,16.....给出一个数字,求组成这个面值有多少种组法? 思路: 用普通母函数解,主要做的就是模拟乘法,因为硬币是无限的,所以每个构造式中每一个项的系数都是1.我们只需要第n项的系数,大于n的并不需要,所以大于n的项就不用再做计算了. #include <bits/stdc++.h> using namespace std; ; int main() { freopen("input.txt", "r…
预处理出完全平方数就和普通的生成函数解整数拆分一样了 #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): 15764    Accepted Submission(s): 10843 Problem Description People in Silverland use square coins. Not only they have square shapes bu…
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…
http://acm.hdu.edu.cn/showproblem.php?pid=2084 数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 28668    Accepted Submission(s): 17230 Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下…
数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 41852    Accepted Submission(s): 24820 Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?…
传送门 真是刷越多题,越容易满足.算是一道很简单的DP了.终于可以自己写出来了. 二维矩阵每个点都有一个幸运值,要求从左上走到右下最多能积累多少幸运值. 重点就是左上右下必须都踩到. dp[i][j] = map[i][j] + max(dp[i-1][j], dp[i][j-1], dp[i][k]) k是j的约数 很简单明了 就是一个细节 当map[1][1]是负数的时候 按这个关系式 dp[1][2]是不会选择从(1,1)出发的 那么就可以把map[1][1]的值加到map[n][m]上…
题意:一个字符串被称为square当且仅当它可以由两个相同的串连接而成. 例如, "abab", "aa"是square, 而"aaa", "abba"不是. 两个长度相同字符串之间的 hamming distance是对应位置上字符不同的位数. 给定一行字符串和 m,输出字典序最小的字符串. 析:首先先用dp判断能不能形成这样的字符串,然后再打印出来,dp[i][j] 表示 i - 中间的数能不能改 j 个字符得到,最后打印…
Description 度度熊是一只喜欢探险的熊,一次偶然落进了一个m*n矩阵的迷宫,该迷宫只能从矩阵左上角第一个方格开始走,只有走到右上角的第一个格子才算走出迷宫,每一次只能走一格,且只能向上向下向右走以前没有走过的格子,每一个格子中都有一些金币(或正或负,有可能遇到强盗拦路抢劫, 度度熊身上金币可以为负,需要给强盗写欠条),度度熊刚开始时身上金币数为0,问度度熊走出迷宫时候身上最多有多少金币? Input 输入的第一行是一个整数T(T < 200),表示共有T组数据. 每组数据的第一行输入两…
题意: 就是现在给出m个串,每个串都有一个权值,现在你要找到一个长度不超过n的字符串, 其中之前的m个串每出现一次就算一次那个字符串的权值, 求能找到的最大权值的字符串,如果存在多个解,输出最短的字典序最小的串. 当最大全权值为0时输出空串. 输入最多100个子串,权值为不超过100的正整数. 每个子串长度至少为1,不超过10, n <= 50 如果不考虑方案输出,这题就变得相当简单了. dp[i][j]表示走到长度为 i 的时候 ,到AC自动机 j 这个节点所获得的最大权值和. 我一开始的做法…
Max Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the m…
Tickets Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 711    Accepted Submission(s): 354 Problem Description Jesus, what a great movie! Thousands of people are rushing to the cinema. However,…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1559 #include <cstring> #include <cstdlib> #include <cstdio> #include <iostream> #include <algorithm> using namespace std; +; <<; int map[maxn][maxn]; //表示以[1,1]为左上角,以[i,j]为右…
题目链接 \(Description\) 有n(n<=10)种硬币,已知每种硬币的数量和它抛一次正面朝上的概率pi.进行如下过程:每次抛一次所有硬币,将正面朝下的硬币去掉.重复该过程直到只剩一种硬币或是没有硬币. 如果结束时还剩下一种硬币,那称它是 \(LuckyCoin\).求每种硬币成为 \(LuckyCoin\) 的概率. \(Solution\) 我们只需要枚举在第j轮,硬币i死亡(这个词形象233),其它硬币在第j轮之前死亡的概率. 由给出的概率及六位小数可以看出,枚举到100轮就很够…
命运 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 15663    Accepted Submission(s): 5486 Problem Description 穿过幽谷意味着离大魔王lemon已经无限接近了! 可谁能想到,yifenfei在斩杀了一些虾兵蟹将后,却再次面临命运大迷宫的考验,这是魔王lemon设下的又一个机关.要知…
有m种不同的句子要组成一首n个句子的歌,每首歌都有一个美丽值,美丽值是由相邻的句子种类决定的,给出m*m的矩阵map[i][j]表示第i种句子和第j种句子的最大得分,一首歌的美丽值是由sum(map[i][i+1],map[i+1][i+2]....) 初始给出n个句子的值,为正就不能改变,为负表示可以替换,输出最大的美丽值. dp[i][j]表示前i个句子且第i个句子种类为j的最大得分.下面分情况讨论. if(p[i]>0) if(p[i-1]>0)  dp[i][p[i]]=dp[i-1]…
题意:自己看题目,中文体面. 题解: 把所有不能走的路径放入AC自动机中. 然后DP[i][j]表示走到 i 这个点,且位于AC自动机 j 这个节点最短距离 然后直接DP即可.注意一点会爆int #include <set> #include <map> #include <stack> #include <queue> #include <cmath> #include <ctime> #include <cstdio>…
题意: 有一个圆圆的毯,被平均分成三个扇形.分为标记为A,B,C. 小余从A开始跳,每次可跳到相邻的扇形上.(A->B 或 A->C) 问小余跳n次,最后回到扇形A的方案数是多少. 思路: A,B,C是三个状态.我们画一棵生长的树,一层一层下来,然后发现每一层上其实最多就只有三种状态.所以明显是可以用DP解喽 直接看代码., 代码: int main(){ int n; int f[1005][5]; while(cin>>n,n){ f[0][0]=1; f[0][1]=0; f…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33384    Accepted Submission(s): 15093 Problem Description Nowadays, a kind of chess game called “Super Jumping!…