HDU 5389 Zero Escape (MUT#8 dp优化)】的更多相关文章

[题目链接]:pid=5389">click here~~ [题目大意]: 题意: 给出n个人的id,有两个门,每一个门有一个标号,我们记作a和b,如今我们要将n个人分成两组,进入两个门中,使得两部分人的标号的和(迭代的求.直至变成一位数,我们姑且叫做求"和"操作~)各自等于a和b,问有多少种分法. [思路]:比赛的时候还是学弟递推的方程.当时是dp三维dp[i][j]k]:分别表示枚举到第i位,A门.B门的状态,可是一直没想到怎么进一步优化,卡在100n的复杂度了 赛…
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5389 Problem Description Zero Escape, is a visual novel adventure video game directed by Kotaro Uchikoshi (you may hear about ever17?) and developed by Chunsoft. Stilwell is enjoying the first chapter o…
题目:http://acm.hdu.edu.cn/showproblem.php? pid=5389 题意:定义数根:①把每一位上的数字加起来得到一个新的数,②反复①直到得到的数仅仅有1位.给定n,A,B和n个一位数,求把这n个数分成两部分,使得这两部分的当中一部分的和的数根等于A另外一部分的和的数根等于B的方案数. 分析:一个数a的数根s=(a-1)%9+1,为了方便直接用s=a%9,当中0代表9.定义dp[i][j]表示前i个数中数根为j的方案数. 对于第i个数能够选也能够不选,那么状态转移…
Zero Escape Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 864    Accepted Submission(s): 438 Problem Description Zero Escape, is a visual novel adventure video game directed by Kotaro Uchik…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4734 题意:我们定义十进制数x的权值为f(x) = a(n)*2^(n-1)+a(n-1)*2(n-2)+...a(2)*2+a(1)*1,a(i)表示十进制数x中第i位的数字. 题目给出a,b,求出0~b有多少个不大于f(a)的数 显然这题可以设这样的dp dp[len][count]表示前len位权值为count的有多少,然后显然的在len==0时return count>=f(a); 但是这样…
Count the string Problem Description It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string. For example:s: "abab"The prefi…
Problem Description Zero Escape, is a visual novel adventure video game directed by Kotaro Uchikoshi (you may hear about ever17?) and developed by Chunsoft. Stilwell is enjoying the first chapter of this series, and in this chapter digital root is an…
Zero Escape Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 407    Accepted Submission(s): 190 Problem Description Zero Escape, is a visual novel adventure video game directed by Kotaro Uchiko…
题意:有一些人,每人拿一个号码,有两个门,门的值分别为A和B,要求把人分成两堆(可以为空)一堆人手持号码之和的数字根若等于A或者B就可以进入A门或者B门,要求两堆人分别进入不同的门,求有几种分配方式,如果A和B的值相等则算两种. 解法:dp.比赛的时候并不知道一个数%9+1就是数字根……煞费苦心的算了半天……只得出结论a+b的数字根等于a的数字根+b的数字根的数字根……没打表……于是T了……然后打了个表才过orz 设dp[i][j]表示用前i个人获得数字根为j的和的方案数,打一个表vector<…
题目传送门 /* 题意:把N个数分成两组,一组加起来是A,一组加起来是B,1<=A,B<=9,也可以全分到同一组.其中加是按照他给的规则加,就是一位一位加,超过一位数了再拆分成一位一位加. DP:dp[i][j]记录前i个数累加和为j的方案数,那么状态转移方程:dp[i][j+a[i]] += dp[i-1][j]; 当然,dp[i][a[i]] = 1; 然后考虑几种特殊情况:都前往S1门或S2门,方案数+1.另外,比赛时我写出正确的转移方程,结果答案输出dp[n][s1]+dp[n][s2…