摘要: #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define go continue #define int long long #define PII pair<int, int> 阅读全文
posted @ 2022-03-08 11:12 std&ice 阅读(84) 评论(0) 推荐(0) 编辑
摘要: /**\ https://ac.nowcoder.com/acm/problem/14526 01背包问题变种 \**/ #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define 阅读全文
posted @ 2022-03-07 23:01 std&ice 阅读(57) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 https://codeforces.com/contest/1646/problem/C 3 题意给出一个数n,选择阶乘数和2次幂数的组合成n,求使用个数最小 4 两种做法: 5 1、dfs 暴力搜索(这道题dfs快点) 6 2、二进制状态压缩枚举 7 \**/ 8 #inclu 阅读全文
posted @ 2022-03-07 17:02 std&ice 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 1 for(int i = 0; i < (1 << n); i++) //0~2^n-1个状态 2 { 3 for(int j = 0; j < n; j++) 4 { 5 if(i & (1 << j)) //check每一位 6 { 7 8 } 9 } 10 } 阅读全文
posted @ 2022-03-07 16:58 std&ice 阅读(58) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 记录操作1的最后一次出现的地方,(前面操作都没有用), 3 然后对比他的下一次操作二的最大值(这里处理一个后缀最大值即可) 4 \**/ 5 #include <bits/stdc++.h> 6 using namespace std; 7 #define fi first 8 # 阅读全文
posted @ 2022-03-04 17:51 std&ice 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 https://www.luogu.com.cn/problem/P3386 3 二分图最大匹配匈牙利算法: 4 假设左部是男孩,右部是女孩 5 1、对于一个男孩子,如果他喜欢女孩y,女孩y没有配偶,就在一起 6 2、如果y有配偶了,x还是想去挖一手墙脚,y也不是什么好女人, 7 阅读全文
posted @ 2022-03-04 15:10 std&ice 阅读(71) 评论(0) 推荐(0) 编辑
摘要: /**\ 最短路模板 输入: n m s t 接下来m行 u, v, w表示u -> v 有一条权值为w的无向边 input: 3 3 1 2 1 2 3 2 3 4 1 3 5 output: 3 \**/ #include <bits/stdc++.h> using namespace std; 阅读全文
posted @ 2022-03-04 11:23 std&ice 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 https://codeforces.com/problemset/problem/1623/C 3 核心代码:运过来的石子够mid个,将a[i]全部甩过去,不然就把多出来的分到后面 4 int add = min(a[i], aa[i] - x) / 3; 5 \**/ 6 #i 阅读全文
posted @ 2022-03-04 09:49 std&ice 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 1 /**\ 2 https://codeforces.com/contest/1426/problem/C 3 先自增再进行复制,这样最优,把一个数从1变成x,需要x-1次。 4 然后暴力枚举一遍,找到最小值就行了 5 \**/ 6 #include <bits/stdc++.h> 7 using 阅读全文
posted @ 2022-03-03 22:10 std&ice 阅读(51) 评论(0) 推荐(0) 编辑
摘要: 1 int primes[N], cnt; // primes[]存储所有素数 2 bool st[N]; // st[x]存储x是否被筛掉 3 4 void get_primes(int n) 5 { 6 for (int i = 2; i <= n; i ++ ) 7 { 8 if (!st[i 阅读全文
posted @ 2022-03-03 15:18 std&ice 阅读(60) 评论(0) 推荐(0) 编辑