摘要: 放苹果 tzoj2679 描述 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。 输入 第一行是测试数据的数目t(0 <= t <= 20)。以下每行均包含二个整数M和N,以空格分开。1<=M,N<=10。 输出 阅读全文
posted @ 2020-07-09 14:32 -第4题- 阅读(185) 评论(0) 推荐(0) 编辑
摘要: http://www.tzcoder.cn/acmhome/problemdetail.do?method=showdetail&id=5752 题意:求两个串的最长公共子序列(顺序相同即为子序列) dp[i+1][j+1]:表示0-i前i+1个为止的最长公共子序列 当a[i]==b[j]时,直接就 阅读全文
posted @ 2020-06-08 16:45 -第4题- 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 1.01背包: 选或不选这件 记dp[i+1][j]为从0到i这i+1个物品中挑选 总重小于j时,总价值的最大值 dp[i+1][j]=dp[i][j](j<w[i]时) dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i])(其他) int dp[MAX_N+1][ 阅读全文
posted @ 2020-05-25 10:12 -第4题- 阅读(260) 评论(0) 推荐(1) 编辑
摘要: 5985: 矩形嵌套 题意:求最长递增子序列(包含两个元素) 思路:先找出关系式子; li=lj+1(当ai<aj时) 两层循环 第一层i从1-n 第二层j 从0-i ;求出i前面的每个j 的max长度再加上自己即1 so要初始化dp【0-n】=1 #include<bits/stdc++.h> u 阅读全文
posted @ 2020-05-25 10:09 -第4题- 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 将一系列给定数字顺序插入一个初始为空的小顶堆H[]。随后判断一系列相关命题是否为真。命题分下列几种: x is the root:x是根结点; x and y are siblings:x和y是兄弟结点; x is the parent of y:x是y的父结点; x is a child of y 阅读全文
posted @ 2020-05-16 10:50 -第4题- 阅读(602) 评论(0) 推荐(0) 编辑
摘要: http://www.tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=3613 算出两两之间min距离,然后从起点开始循环时间点,到的了的地方进队 #include<bits/stdc++.h> using namespace st 阅读全文
posted @ 2020-05-16 10:23 -第4题- 阅读(172) 评论(0) 推荐(0) 编辑
摘要: gcd(2^x-1,2^y-1)=2^gcd(x,y)-1; gcd(Fib[x],Fib[y])=Fib[gcd(x,y)]; Fbi[n]/Fbi[n+1]≈0.618 (n较大时,7开始就可) Fib[1]+Fib[2]+Fib[3]+...+Fib[n]=Fib[n+2]-1; Fib[1] 阅读全文
posted @ 2020-05-16 10:04 -第4题- 阅读(176) 评论(0) 推荐(0) 编辑
摘要: Given a sequence with n elements, if the last element is also adjacent to the first element of the sequence, the sequence is called “circular sequence 阅读全文
posted @ 2020-05-16 10:00 -第4题- 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 反向拓扑:(正向行不通,这题要求序号小的尽量排前面,而不是要求字典序) 比如输入: 1 3 1 3 1 则仅有3指向1,正向拓扑结果是2,3,1;但并不是正确结果 题目要求序号小尽量排前面,可以是3,1,2;这样1就往前排了 所以用反向拓扑,把图画反,用优先队列(大到小)进行拓扑(保证小的在后),最 阅读全文
posted @ 2020-05-15 22:59 -第4题- 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3685 ac代码: #include<bits/stdc++.h> #define ll long long #define maxn 50010 using namespace std; const d 阅读全文
posted @ 2020-05-15 16:57 -第4题- 阅读(184) 评论(0) 推荐(0) 编辑