摘要: A 首先把原数组中的数按题目要求进行转化 状态表示$f[i][j]$表示从前$i$个选,凑成的数组为$j$的所有方案数 #include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 10 阅读全文
posted @ 2022-01-27 14:25 Angels_of_Death 阅读(67) 评论(0) 推荐(0)
摘要: A #include <bits/stdc++.h> using namespace std; int main() { puts("All in!"); return 0; } B #include <bits/stdc++.h> using namespace std; int T, n, m, 阅读全文
posted @ 2022-01-26 23:20 Angels_of_Death 阅读(290) 评论(0) 推荐(0)
摘要: 黑白染色模板题 首先通过DFS缩点,将所有相同状态的连通块缩成一个点 之后枚举每一个点进行BFS,计算变成最终状态的最小值 #include<bits/stdc++.h> using namespace std; const int N = 50, M = 2500; int T, n, m, cn 阅读全文
posted @ 2022-01-26 09:48 Angels_of_Death 阅读(35) 评论(0) 推荐(0)
摘要: $f[A][B][C][D][X][Y]$表示当前由A张红桃,B张黑桃,C张梅花,D张方片,且小王的状态为X,大王的状态为Y的情况的期望的最小值 此时可以通过枚举每一个变量的状态得到状态转移 #include <bits/stdc++.h> using namespace std; const in 阅读全文
posted @ 2022-01-26 09:40 Angels_of_Death 阅读(33) 评论(0) 推荐(0)
摘要: 正推概率,逆推期望 $f[i]$表示从$i$到$N$的概率 递推方程:\(f[i] = \sum (\frac{1}{k} \times (w[i] + f[j]))\) #include <bits/stdc++.h> using namespace std; const int N = 1e5 阅读全文
posted @ 2022-01-25 16:06 Angels_of_Death 阅读(27) 评论(0) 推荐(0)
摘要: 二分 + 前缀和 首先我们可以二分平均数 对于长度不小于L的子段, (1)等价于原数组中的每个数减去平均数,计算度不小于L的子段使得和大于0 (2)通过一个变量维护,$(0,i-L)$中前缀和的最小值 #include <bits/stdc++.h> using namespace std; con 阅读全文
posted @ 2022-01-24 17:42 Angels_of_Death 阅读(34) 评论(0) 推荐(0)
摘要: AcWing 3164. 线性基 由高到低枚举二进制的每一位 通过高斯消元化为上三角矩阵 后将所有元素异或即可 #include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 10; in 阅读全文
posted @ 2022-01-24 16:01 Angels_of_Death 阅读(86) 评论(0) 推荐(0)
摘要: A #include <bits/stdc++.h> using namespace std; int main() { string s; int a, b; cin >> s >> a >> b; swap(s[a - 1], s[b - 1]); cout << s << endl; retu 阅读全文
posted @ 2022-01-24 10:13 Angels_of_Death 阅读(96) 评论(0) 推荐(0)
摘要: A #include <bits/stdc++.h> using namespace std; int n, k; struct node { int a, b; }p[110]; bool cmp(node x, node y) { if (x.a == y.a) return x.b > y.b 阅读全文
posted @ 2022-01-23 16:05 Angels_of_Death 阅读(29) 评论(0) 推荐(0)
摘要: A class Solution { public: int minimumCost(vector<int>& cost) { sort(cost.begin(), cost.end()); vector<int> v; int sum = 0; for (int i = cost.size() - 阅读全文
posted @ 2022-01-23 14:33 Angels_of_Death 阅读(35) 评论(0) 推荐(0)