上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 23 下一页

2021年1月18日

摘要: https://www.acwing.com/problem/content/424/ 1、直接模拟 1 #include<iostream> 2 using namespace std; 3 const int N=10010; 4 bool a[N]; 5 int main(void){ 6 i 阅读全文
posted @ 2021-01-18 09:10 greenofyu 阅读(73) 评论(0) 推荐(0)

2021年1月15日

摘要: 状态表示 f[i][j] 集合:考虑前 i 组物品,体积不超过 j 的取法的价值的集合 属性:最大值 状态计算:f ( i , j ) = f ( i-1 , j) , f ( i-1 , j-v1) + w1 , f ( i , j ) = f ( i-1 , j-v2) + w2 .....最大 阅读全文
posted @ 2021-01-15 21:21 greenofyu 阅读(160) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/1229/ 这个问题也是不好直接求值,但是给定值很好判定这个值是不是可以的,所以也可以用二分解决。 不过整数二分略微有点难写。 1 #include<iostream> 2 #include<climits> 3 usin 阅读全文
posted @ 2021-01-15 14:56 greenofyu 阅读(75) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/682/ 直接求答案并不好求,但是如果给定确定的绳子的长度,问是否能够剪出这么多根是可以在O(n)的复杂度内求出来的。 所以可以将求值问题转化为一个判定问题,这样就可以使用二分来做了。 1 #include<iostrea 阅读全文
posted @ 2021-01-15 14:53 greenofyu 阅读(173) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/1348/ 主要考察进位制的转换,数据范围较小,所以并不需要考虑时间复杂度的问题。 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 c 阅读全文
posted @ 2021-01-15 14:50 greenofyu 阅读(90) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/1115/ Flood Fill算法,对于格子问题,求连通块的最大数量 有两种写法,BFS和DFS BFS 1 #include<iostream> 2 #include<queue> 3 #include<cstring 阅读全文
posted @ 2021-01-15 14:46 greenofyu 阅读(115) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/758/ 模拟题 1 #include<iostream> 2 using namespace std; 3 const int N=110; 4 int a[N][N]; 5 int u[]={-1,0,1,0}; 6 阅读全文
posted @ 2021-01-15 14:44 greenofyu 阅读(97) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/900/ 典型的DP问题,状态表示f[i][j] 集合:所有从顶部走到当前位置的路径上的数字和的集合 属性:最大值 状态计算:f [ i ] [ j ]= max ( f[i-1][j-1] , f[i-1][j] )+a 阅读全文
posted @ 2021-01-15 14:41 greenofyu 阅读(125) 评论(0) 推荐(0)
摘要: 题目:https://www.acwing.com/problem/content/106/ 贪心,将商店从0~n-1编号 如果n是奇数,将货仓放在第n/2个商店上就可以了 如果n是偶数,将货仓放在n/2-1和n/2商店之间就可以了 1 #include<iostream> 2 #include<c 阅读全文
posted @ 2021-01-15 14:38 greenofyu 阅读(114) 评论(0) 推荐(0)

2021年1月7日

摘要: A、长和宽一直除二到奇数就好了 1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<queue> 6 #include<vector> 7 using namespa 阅读全文
posted @ 2021-01-07 11:48 greenofyu 阅读(82) 评论(0) 推荐(0)
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 23 下一页