lightoj 1381 - Scientific Experiment dp】的更多相关文章

1381 - Scientific Experiment Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://www.lightoj.com/volume_showproblem.php?problem=1381 Description John wants to be a scientist. A first step of becoming a scientist is to perform experiment. John has de…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1032 #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <queue> #include <vector> using namespace std; ;…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1017 搞了一个下午才弄出来,,,,, 还是线性DP做的不够啊 看过数据量就知道状态转移方程和x,没有关系 然后再仔细推导就会知道整个转移方程只和k与y的差值有关 然后继续推导.... 定义dp[i][j]表示表示第j步删除最上边的i点, 定义mv[i]表示删除i点的同时可以向下移动的最远位置(可以预处理出来) 那么dp[i][j]=max(dp[i-1][j],dp[i-mv…
problem=1068">http://www.lightoj.com/volume_showproblem.php?problem=1068 求出区间[A,B]内能被K整除且各位数字之和也能被K整除的数的个数.(1 ≤ A ≤ B < 231 and 0 < K < 10000) 算是最简单的数位dp了.k在这里是10000.三维数组都开不开.可是想想会发现A,B最多有10位,各位数字之和不会超过90.那么当 k >= 90时,就不用dp,由于个位数字之和对k取…
题目链接: Lightoj  1044 - Palindrome Partitioning 题目描述: 给一个字符串,问至少分割多少次?分割出来的子串都是回文串. 解题思路: 先把给定串的所有子串是不是回文串处理出来,然后用dp[i] 表示 从起点到串i的位置的最少分割次数,然后结合处理出来的回文串转移一下即可! 还是好蠢哦!自己竟然感觉是一个区间DP,但是n又那么大,完全不是区间DP的作风啊! #include <cmath> #include <cstdio> #include…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1084 题解:不妨设dp[i] 表示考虑到第i个点时最少有几组那么 if a[i]-a[i-j]<=2*k (j>=2) then dp[i]=min(dp[i],dp[i-j]+1).所以先要排序,然后用二分找到最小的j然后用线段树或者其他的方法查询(i-1~i-j)的最小值. #include <iostream> #include <cstring&g…
You are x N grid. Each cell of the cave can contain any amount of gold. Initially you are . Now each turn you sided dice. If you get X in the dice after throwing, you add X to your position and collect all the gold from the new position. If your new…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1027 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int sum,ans,n,m; int Gcd(int a,int b){ ) return b; return Gcd(b,a%b); } int…
题目:click here 分明就是贪心怎么会在dp的专题 #include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; const int INF = 0x3f3f3f3f; ; struct Node { int F, S; bool operator < ( const Node x ) const { return S < x.S; } } p[M]; int n; int main…
借鉴自:https://www.cnblogs.com/keyboarder-zsq/p/6216762.html 题意:n个格子,每个格子有一个值.从1开始,每次扔6个面的骰子,扔出几点就往前几步,然后把那个格子的金子拿走: 如果扔出的骰子+所在位置>n,就重新扔,直到在n: 问取走这些值的期望值是多少 解析: [1] [2] [3][4] [5] [6] [7] [8] [9] //格子和值都是一样,所以下述的话,值就是格子,格子就是值... 比如这样的9个格子,我们总底往上来 对于第9个格…