欢迎访问我的个人网站==》 jiashubing.cn
摘要: Anagrams by Stack题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4题目大意:输入两个字符串序列,判断能否通过对第一个字符串进行进栈出栈操作得到第二个字符串,若能则输出所有能达到的进出栈操作过程。我通过全排列每得到一组操作过程,则用函数按照这个操作过程,判断能否得到第二个字符串,若能则表明此操作过程可行,输出。代码如下: 1 # include 2 # include 3 # include 4 # include 5 using namespace std; 6 7 string str1,st. 阅读全文
posted @ 2013-08-15 03:59 贾树丙 阅读(391) 评论(0) 推荐(0)
摘要: Undercut题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=57题目大意:a card game,two player,每个player有n张牌,按顺序出牌,如果2张牌的点数相等,2个player都不得分;如果2张牌点数相差1,点数大的player得分为2张牌的点数和;如果2张牌的点数相差超过1,点数大的player得分为点数大的牌的点数;特殊情况,如果2张牌的点数分别为1和2,持2的player得分为6而不是3;给出2个player各n张牌的点数,要求输出每个player的得分情况代码如下: 1 # incl 阅读全文
posted @ 2013-08-15 03:31 贾树丙 阅读(541) 评论(0) 推荐(0)
摘要: Chopsticks题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=234题目大意:给定n个筷子的长度,取k+8套筷子,每套有3个,长度分别为A,B,C。要求k+8套筷子中(A-B)^2的和最小,输出这个最小值。分析:题目中筷子长度是非降序排列的,所以最小的两个A和B一定是相邻的。先不考虑筷子C,只要留着就行。 令dp[i][j]表示从 j 个筷子中取 i 套筷子的最优值。 dp[i][j] = min {dp[i][j-1] , dp[i-1][j-1] | (n - j > 3*(k - i))剩下的筷子 阅读全文
posted @ 2013-08-15 02:56 贾树丙 阅读(666) 评论(0) 推荐(0)
摘要: Common SubsequenceTime Limit:2 Seconds Memory Limit:65536 KBA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exists a strictly increasing sequence of indices of X such that... 阅读全文
posted @ 2013-08-15 02:40 贾树丙 阅读(327) 评论(0) 推荐(0)