上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 22 下一页

2021年1月20日

摘要: https://www.acwing.com/problem/content/1534/ 算法一:hashmap 对于每一个数a,看m-a是否出现过。取其中的a最小的值。 1 #include<iostream> 2 #include<unordered_set> 3 #include<algori 阅读全文
posted @ 2021-01-20 20:36 greenofyu 阅读(121) 评论(0) 推荐(0)

2021年1月18日

摘要: https://www.acwing.com/problem/content/1210/ 贪心,直接枚举源串,若和目标串不同,则进行操作。 两个性质:最多n-1种操作 每种操作执行0次或者1次 1 #include<iostream> 2 using namespace std; 3 void ch 阅读全文
posted @ 2021-01-18 09:42 greenofyu 阅读(72) 评论(0) 推荐(0)
摘要: 考察排序。 https://www.acwing.com/problem/content/431/ 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 const int N=310; 5 struct node{ 阅读全文
posted @ 2021-01-18 09:25 greenofyu 阅读(55) 评论(0) 推荐(0)
摘要: 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 阅读(68) 评论(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 阅读(152) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/1229/ 这个问题也是不好直接求值,但是给定值很好判定这个值是不是可以的,所以也可以用二分解决。 不过整数二分略微有点难写。 1 #include<iostream> 2 #include<climits> 3 usin 阅读全文
posted @ 2021-01-15 14:56 greenofyu 阅读(70) 评论(0) 推荐(0)
摘要: https://www.acwing.com/problem/content/682/ 直接求答案并不好求,但是如果给定确定的绳子的长度,问是否能够剪出这么多根是可以在O(n)的复杂度内求出来的。 所以可以将求值问题转化为一个判定问题,这样就可以使用二分来做了。 1 #include<iostrea 阅读全文
posted @ 2021-01-15 14:53 greenofyu 阅读(169) 评论(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 阅读(107) 评论(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 阅读(93) 评论(0) 推荐(0)
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 22 下一页