
dp
Healer66
他是谁啊?他究竟是什么身份啊?
展开
-
Gym - 101002F Mountain Scenes (dp)
链接:https://vjudge.net/problem/Gym-101002F题意:给出总长度,和框的宽和高,问有多少种摆法使得摆出来的图案不是平的。思路:dp[i][j]代表到第i列为止用了j米长的情况数,下一状态等于前一状态的各种情况的总和,比如说求i=5,j=10的情况数,应该i=4时,j=0,1,2,3,4,5,6,7,8,9,10的情况之和。#include...原创 2018-10-03 09:52:16 · 325 阅读 · 0 评论 -
HRBUST - 1818 - 石子合并问题--直线版 (区间dp)
题意:相邻石堆可以合并,每次合并花费为石子数和,问最终合并为一堆时的花费最少和最多分别是多少思路:先枚举区间长度,在枚举端点。端点将区间分为两个,然后合并。dpn[i][j] = min(dpn[i][j],dpn[i][k] + dpn[k+1][j]+sum[j]-sum[i-1]);表示 在该长度内任意两个区间合并所求的最小值。#include <iostre...原创 2019-03-08 11:24:19 · 414 阅读 · 0 评论 -
HDU - 5887- Herbs Gathering(搜索/剪枝)
题意:n个物品,时间限制m;给出每个物品的价值和时间;求在m限制内,最多的价值。 #include <bits/stdc++.h>using namespace std;const int maxn = 200;typedef long long ll;struct Node{ ll x,y; bool operator < (...原创 2019-02-08 22:07:27 · 362 阅读 · 0 评论 -
Gym - 101502J - Boxes Game(dp && 博弈)
#include <bits/stdc++.h>using namespace std;const int maxn = 2000;int dp[maxn][maxn],a[maxn],sum[maxn];int dfs(int x,int y){ if(dp[x][y] != -1) return dp[x][y]; if( x == y) return...原创 2019-01-29 21:25:46 · 332 阅读 · 0 评论 -
Gym - 101502D - Dice Game (dp)
/* dp[i][j]表示和为i时,当前数字是j时的最小步数 dir[i]保存与数字i相邻的四个数字*/#include<bits/stdc++.h>using namespace std;const int inf=0x3f3f3f3f;int dir[7][4]= {{1,1,1,1},{2,3,4,5},{1,3,4,6},{1,2,5,6},{1,2,5...原创 2019-01-26 12:04:16 · 342 阅读 · 0 评论 -
Kattis - canonical- Canonical Coin Systems (dp&&贪心)
链接:https://vjudge.net/contest/263769#problem/C题意:问一种货币体系,对于任意数量的money,按照贪心和dp完全背包的做法拼凑,用的纸币数量是否一致。思路:分别跑,比较即可。#include <bits/stdc++.h>using namespace std;const int INF = 0x3f3f3f3...原创 2018-10-27 11:20:29 · 610 阅读 · 0 评论 -
51Nod-1183-编辑距离
编辑距离算法详解编辑距离,又称Levenshtein距离(也叫做Edit Distance),是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。例如将kitten一字转成sitting:sitten (k->s)sittin (e->i)sitting (->g)所以kitt...原创 2018-10-08 09:27:16 · 276 阅读 · 0 评论 -
Aizu - 1378 - Secret of Chocolate Poles (DP)
Wendy, the master of a chocolate shop, is thinking of displaying poles of chocolate disks in the showcase. She can use three kinds of chocolate disks: white thin disks, dark thin disks, and dark thic...原创 2018-09-04 08:46:45 · 305 阅读 · 0 评论 -
Gym - 101667C—Game Map (dp)
题目链接:https://odzkskevi.qnssl.com/6fd8c99567698f4bad5a228cc982bad7?v=1535352582题意:攻打城市,每次只能走相邻且度数更大的城市,问最多攻打多少。思路:看代码吧#include <vector>#include <cstdio>#include <cstring&g...原创 2018-09-06 21:19:38 · 445 阅读 · 0 评论 -
poj1159 Palindrome (简单dp&&滚动数组)
链接:http://poj.org/searchproblem?field=source&key=IOI+2000题意:至少增添多少个字符可以使原字符串变成回文串思路:原字符串反转,求最长公共子序列长度,剩余的长度就是需要加的字符数这里用到了滚动数组,因为该次的dp其实只取决去前一次的dp#include <iostream>#include &...原创 2018-09-27 21:59:47 · 547 阅读 · 1 评论 -
POJ - 2955 - Brackets(区间dp)
思路:dp[i][j] 表示 i到j内的最大匹配数。更新:如果s[i] 和 s[j] 相匹配,则dp[i][j] = dp[i+1][j-1] + 2;#include <iostream>#include <string.h>using namespace std;const int maxn =110;int dp[maxn][maxn];str...原创 2019-03-12 16:11:25 · 160 阅读 · 0 评论