随笔分类 -  动态规划

摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 using namespace std; 14 typedef long lon... 阅读全文
posted @ 2018-08-05 00:54 ouyang_wsgwz 阅读(123) 评论(0) 推荐(0) 编辑
摘要:1 #include <stdio.h> 2 #include <algorithm> 3 using namespace std; 4 5 typedef long long ll; 6 const int mod = 1e9 + 7; 7 int dp[1010][10000]; 8 // dp 阅读全文
posted @ 2018-04-15 20:23 ouyang_wsgwz 阅读(111) 评论(0) 推荐(0) 编辑
摘要:题意: 第一类物品的价值为k1,第二类物品价值为k2,背包的体积是 c ,第一类物品有n 个,每个体积为S11,S12,S13,S14.....S1n ; 第二类物品有 m 个,每个体积为 S21,S22,S23,S24.......S2m; 每次装入物品时,得到的价值是 剩余背包体积*该类物品的价 阅读全文
posted @ 2018-04-08 20:27 ouyang_wsgwz 阅读(233) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #define MAXN 50010 5 using namespace std; 6 7 const int MIN = -1e9; 8 9 int main(void){ 10 int n, a[MAXN], vis[MAXN], len = 1; 11 scanf("%d",... 阅读全文
posted @ 2018-04-06 09:50 ouyang_wsgwz 阅读(210) 评论(0) 推荐(0) 编辑
摘要:1 //完全背包的变形 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int MOD = 1e9 + 7; 8 const int maxn = 100000 + 5; 9 int a[13] = { 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, ... 阅读全文
posted @ 2018-04-05 16:27 ouyang_wsgwz 阅读(124) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 const int maxn = 50000 + 5; 7 long long a[maxn]; 8 long long l[maxn], r[maxn]; 9 10 int main(){ 11 ios::sync_with_stdio(f... 阅读全文
posted @ 2018-04-02 20:07 ouyang_wsgwz 阅读(140) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 6 #define INF 0xfffffff 7 using namespace std; 8 const int maxn = 100 + 5; 9 int a[maxn]; 10 int sum[maxn]; 11 int dp[maxn][maxn]; 12 //dp[... 阅读全文
posted @ 2018-04-02 19:43 ouyang_wsgwz 阅读(182) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 const int maxn = 10000 + 5; 7 int a[maxn]; 8 int f[maxn][15]; 9 10 void rmq(int cnt){ 11 memset(f, 0, sizeof(f)); 12 ... 阅读全文
posted @ 2018-03-28 21:52 ouyang_wsgwz 阅读(138) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 const int maxn = 1000000 + 5; 7 int v[maxn]; 8 int c[maxn]; 9 int dp[maxn]; 10 11 int main(){ 12 ios::sync_with_stdio(fal... 阅读全文
posted @ 2018-03-26 21:58 ouyang_wsgwz 阅读(133) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int maxn = 1010; 8 char a[maxn], b[maxn]; 9 int f[maxn][maxn]; 10 string s; 11 12 int main() 13 { 14 scanf(... 阅读全文
posted @ 2018-03-15 21:24 ouyang_wsgwz 阅读(121) 评论(0) 推荐(0) 编辑
摘要:最开始毫无头绪,然后参照了一位dalao的博客,思路是一个正序的字符串将其逆序,然后求最长公共子序列(LCS),emm也属于动态规划。 阅读全文
posted @ 2018-03-13 20:31 ouyang_wsgwz 阅读(121) 评论(0) 推荐(0) 编辑
摘要:有两种方式: 1.在首尾之间 2.在尾首之间 对于第一种直接来dp就好,第二种需要将其数组全部取负,然后取到其最大值(肯定是负数的最大值)然后dp即可,最后比较这两个答案谁比较大就输出哪个 阅读全文
posted @ 2018-03-10 20:03 ouyang_wsgwz 阅读(139) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #define ll long long 4 using namespace std; 5 6 void dfs(ll a, ll b, ll c[]) 7 { 8 ll n = a / 10, m = a % 10, t = n; 9 for (int i = 0; i > a >> b; 29 ... 阅读全文
posted @ 2017-12-20 17:06 ouyang_wsgwz 阅读(116) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #define MAXN 510 4 using namespace std; 5 int f[MAXN][MAXN], dp[MAXN][MAXN];// 数字塔数组和dp数组 6 int main() { 7 int n; 8 scanf("%d", &n); 9 for (int i = 1;... 阅读全文
posted @ 2017-11-30 20:46 ouyang_wsgwz 阅读(133) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示
深色
回顶
展开