Dynamic Programming
Saruhiko
这个作者很懒,什么都没留下…
展开
-
区间dp
#include<bits/stdc++.h> using namespace std; const int inf=1e9; int n; int a[310],s[310]; int dp[310][310]; int main(){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i&...原创 2019-12-12 20:56:44 · 105 阅读 · 0 评论 -
背包dp模板
01背包 #include<iostream> #include<cstring> using namespace std; const int maxn=1e5+1000; int n,m; int v[maxn],w[maxn]; int dp[maxn]; int main(){ cin>>n>>m; memset(dp,0,sizeof(...原创 2019-12-12 20:54:43 · 218 阅读 · 0 评论 -
poj2228 Naptime(环形dp)
Description Goneril is a very sleep-deprived cow. Her day is partitioned into N (3 <= N <= 3,830) equal time periods but she can spend only B (2 <= B < N) not necessarily contiguous period...原创 2019-12-12 20:44:26 · 172 阅读 · 0 评论 -
ural 1018 Binary Apple Tree(树形dp)
Description Let’s imagine how apple tree looks in binary computer world. You’re right, it looks just like a binary tree, i.e. any biparous branch splits up to exactly two new branches. We will enumera...原创 2019-12-12 20:21:45 · 170 阅读 · 0 评论 -
poj 2411 Mondriaan's Dream(状态压缩dp)
Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his ‘toilet series’ (where he had to use his toilet paper to draw on, ...原创 2019-12-12 20:10:02 · 110 阅读 · 0 评论