hdu:Two Rabbits(区间DP)】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=4745 题意: 有两只兔子Tom Jerry, 他们在一个用石头围城的环形的路上跳, Tom只能顺时针跳,Jerry只能逆时针跳,  要求在跳的过程中他们所在石头的权值必须相同,而且只能单向跳,中间不能有已经跳过的石头. 思路: 模型就是求环上的最长回文串,我们只要将原串倍增,然后每个长度为n的子串的最长回文串就是我们要求的.区间DP一下就好了, 注意要考虑起点终点是统一点的情况特殊. //#pragma co…
Problem Description Teacher Mai has n numbers a1,a2,⋯,anand n−1 operators("+", "-" or "*")op1,op2,⋯,opn−1, which are arranged in the form a1 op1 a2 op2 a3 ⋯ an.He wants to erase numbers one by one. In i-th round, there are n+…
Problem Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small hall, so it attract a lot of boys and girls. Now there ar…
Dire Wolf Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others)Total Submission(s): 3815    Accepted Submission(s): 2266 Problem Description Dire wolves, also known as Dark wolves, are extraordinarily large and powerfu…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5568 题意: 求所有长度为k的严格升序子序列的个数. 题解: 令dp[i][k]表示以i结尾的长度为k的所有严格升序子序列的个数,则有状态转移:dp[i][k]+=dp[j][k-1](其中,arr[i]>arr[j],并且i>j): 最后答案为dp[1][k]+...dp[n][k]. 代码: import java.util.*; import java.math.*; public cla…
题目大意 给出一个长度为n的环状序列,两只兔子各自从一个点出发,一个顺时针跳,一个逆时针跳,每个时刻都要求两只兔子所在的数字是相同的,兔子最多跳一个圈~~~问兔子们最多能跳多少次 题解 一个逆时针跳,一个顺时针跳,经过的数字刚好组成了一个回文串,所以题目的要求就是求最长的回文,不过序列是环状的!怎么办?我们看看样例:2 1 1 2 1 3 答案是5 即2 1 1 2 1 3,其实就是[1,4]区间的最长回文加上[5,6]区间的最长回文,因此我们枚举中间点i,求出max(dp[1,i]+dp[i+…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4597 #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <queue> #include <vector> using namespace std; ; ; const…
Cake slicing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 149    Accepted Submission(s): 86 Problem Description A rectangular cake with a grid of m*n unit squares on its top needs to be slice…
Two Rabbits Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 1274 Accepted Submission(s): 641 Problem Description Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny aft…
题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=4283 Problem Description The TV shows such as You Are the One has been very popular. In order to meet the need of boys who are still single, TJUT hold the show itself. The show is hold in the Small…