12 2019 档案
摘要:#include<bits/stdc++.h> using namespace std; const int N=5010; int n,m,k; int a[N],b[N],c[N];//攻破所需人数,获得人数,奖励得分 int l[N],d[N],f[N],h[N];//可以扔掉兵攻占i的最晚的
阅读全文
posted @ 2019-12-19 17:03
晴屿
摘要://f[i][j]表示前 i 个字符与字符串匹配长度为 j 时的方案数 #include <cstring> #include <iostream> #include <algorithm> #include <string> using namespace std; const int N=55,
阅读全文
posted @ 2019-12-11 19:32
晴屿
摘要://初始状态(入口)转移到手中无货的第>=2天 //最终状态(出口)可能从手中无货的第一天转移过来,或者从手中无货的第>=2天 //f[i,0]表示走到第i天,且位于手中有货的状态 //f[i,1]表示走到第i天,且位于手中无货的第一天的状态 //f[i,2]表示走到第i天,且位于手中无货的第>=2
阅读全文
posted @ 2019-12-09 14:21
晴屿
摘要://f[i,j,1]表示走到第i天已经进行完j次交易并且手中没有股票的所有的购买方式的集合 //f[i,j,0]表示走到第i天并且正在进行第j次交易且手中有货的所有的购买方式的集合 //属性利益最大值 //f[i,j,0]=max(f[i-1,j,0],f[i-1,j,1]+w[i]) //表示从手
阅读全文
posted @ 2019-12-09 14:02
晴屿
摘要://f[i,j]表示所有走了i步,且当前位于状态j的所有走法 j=1表示选第i个 j=0表示不选 //如果j=0 那么表示不选第i个 那么就可以从f[i-1,0]和f[i-1,1]转移过来 //如果j=1 那么表示选第i个,那么就可以f[i-1,0]+w[i]转移过来 //入口 可以思考一下 //初
阅读全文
posted @ 2019-12-09 13:47
晴屿
摘要://g[i,j]表示f[i,j]取最大值的方案数目 //体积最多是j 全部为0,v>=0 //体积恰好为j f[0][0]=0,f[i]=无穷,v>=0 //体积至少是j f[0][0]=0,f[i]=无穷,体积为负数时于0取大 #include <cstring> #include <iostre
阅读全文
posted @ 2019-12-08 01:50
晴屿
摘要:#include <cstring> #include <iostream> #include <algorithm> using namespace std; const int N = 110; int n, m; int v[N], w[N]; int h[N], e[N], ne[N], i
阅读全文
posted @ 2019-12-08 01:28
晴屿
摘要:#include<iostream> #include<algorithm> #include<cstring> using namespace std ; const int N=1010; int f[N],g[N],q[N]; int n,m; int a[N]; int main() { c
阅读全文
posted @ 2019-12-07 23:06
晴屿
摘要:#include <cstring> #include <iostream> #include <algorithm> using namespace std; const int N = 25010; int n; int a[N]; bool f[N]; int main() { int T;
阅读全文
posted @ 2019-12-07 22:49
晴屿
摘要:#include<iostream> using namespace std; const int MAX=2e5+10; int cnt[MAX]; int ans[MAX]; int a[MAX]; int main() { int n,m,zero=0,one=0; cin>>n>>m; fo
阅读全文
posted @ 2019-12-07 13:37
晴屿
摘要:#include <cstring> #include <iostream> #include <algorithm> #include <vector> #define v first #define w second using namespace std; typedef pair<int,
阅读全文
posted @ 2019-12-07 02:59
晴屿
摘要://分组背包 for物品 for体积 for 决策 #include <iostream> using namespace std; const int N = 20; int n, m; int w[N][N]; int f[N][N]; int way[N];//方案 int main() {
阅读全文
posted @ 2019-12-06 22:24
晴屿
摘要://f[i][j]=max(f[i-1][j],f[i-1][j-v[i]]+w[i]) #include <iostream> using namespace std; const int N = 1010; int n, m; int v[N], w[N]; int f[N][N]; int m
阅读全文
posted @ 2019-12-06 01:21
晴屿
摘要://多重背包 max #include <iostream> using namespace std; const int N = 6010; int n, m; int f[N]; int main() { cin >> n >> m; for (int i = 0; i < n; i ++ )
阅读全文
posted @ 2019-12-04 02:21
晴屿
摘要://M看成背包容量,把每个数看成一个物品,Ai看成是体积 //目标:求总体积恰好为M的方案数目 #include <iostream> using namespace std; const int N = 10010; int n, m; int f[N];//f[i][j]表示从前i个物品种选,和
阅读全文
posted @ 2019-12-04 02:06
晴屿
摘要://体积最多是j 全部为0,v>=0 //体积恰好为j f[0][0]=0,f[i]=无穷,v>=0 //体积至少是j f[0][0]=0,f[i]=无穷,体积为负数时于0取大 #include<cstring> #include<iostream> using namespace std ; co
阅读全文
posted @ 2019-12-04 01:51
晴屿
摘要://完全背包 求方案数目 //f[i][j] 只从前i个物品中选,且总体积恰好为j的方案的集合 //f[i][j]=f[i-1][j]+f[i-1][j-v*1]+f[i-1][j-v*2]+...f[i-1][j-v*s] //f[i][j-v]= f[i-1][j-v*1]+f[i-1][j-v
阅读全文
posted @ 2019-12-04 01:25
晴屿
摘要:#include<iostream> using namespace std ; const int N=1010; int f[N][N]; int V1,V2,n; int main() { cin>>V1>>V2>>n; for(int i=1; i<=n; i++) { int v1,v2;
阅读全文
posted @ 2019-12-03 10:30
晴屿
摘要://因为可以反转n次 所以可以得到任何可以构成的序列 #include<iostream> #include<string> #include<vector> using namespace std ; typedef pair<int,int>PII; int n,k; string s; str
阅读全文
posted @ 2019-12-01 22:09
晴屿
摘要:#include<bits/stdc++.h> using namespace std; int shu[100005]; int ans[100005]; int main() { int total; cin>>total; while(total--) { int n; bool flag=t
阅读全文
posted @ 2019-12-01 03:00
晴屿
摘要://只要从所有区间右端点的最小值覆盖到所有区间左端点的最大值即可 #include<iostream> using namespace std ; int x,y; int n; int t; int main() { cin>>t; while(t--) { cin>>n; if(n==1) {
阅读全文
posted @ 2019-12-01 01:48
晴屿