随笔分类 - acm
摘要:A class Solution { public: vector<int> sortEvenOdd(vector<int>& nums) { vector<int> a, b, v; for (int i = 0; i < nums.size(); i ++ ) if (i % 2 == 0) a
阅读全文
摘要:#include <bits/stdc++.h> #define LL long long using namespace std; const int N = 5e5 + 10; int n, m, len; LL ans; int a[N], num[N]; struct node { int
阅读全文
摘要:A #include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n; cin >> n; if (n == 1) {puts("Yes"); return 0;} if (n > 4)
阅读全文
摘要:#include <bits/stdc++.h> #define LL long long using namespace std; const int N = 2e5 + 10; int T, n, m, p; int w[N]; struct node { int l, r; int mul;
阅读全文
摘要:#include <bits/stdc++.h> #define LL long long using namespace std; const int N = 2e5 + 10; int n, m; int w[N]; struct node { int l, r; int tag; }tr[N
阅读全文
摘要:#include <bits/stdc++.h> #define LL long long using namespace std; const int N = 2e5 + 10; int n, m; int w[N]; struct node { int l, r; int Max; }tr[N
阅读全文
摘要:#include <bits/stdc++.h> #define LL long long using namespace std; const int N = 1e5 + 10; int n, m, p; int w[N]; struct Node { int l, r; int sum, add
阅读全文
摘要:#include <bits/stdc++.h> #define LL long long using namespace std; const int N = 1e5 + 10; int n, m; LL w[N]; struct node { int l, r; LL sum, add; }tr
阅读全文
摘要:A 暴力 #include <bits/stdc++.h> using namespace std; int T, a, b; int main() { cin >> T; while (T -- ) { int n; cin >> n; vector<int> v; while (n) { v.p
阅读全文
摘要:A #include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int T, n; int main() { cin >> T; while (T -- ) { cin >> n; string s; cin >> s;
阅读全文
摘要:A #include <bits/stdc++.h> #define int long long using namespace std; int T, n, m; signed main() { cin >> n; int a = 2147483648; int b = a * -1; a --;
阅读全文
摘要:A #include <bits/stdc++.h> using namespace std; int a[10010], b[10010]; int main() { int T; cin >> T; while (T -- ) { int n; cin >> n; for (int i = 1;
阅读全文
摘要:A class Solution { public: int findFinalValue(vector<int>& nums, int original) { for (int i = 1; i <= 1000; i ++ ) { for (auto x : nums) { if (x == or
阅读全文
摘要:A 首先把原数组中的数按题目要求进行转化 状态表示$f[i][j]$表示从前$i$个选,凑成的数组为$j$的所有方案数 #include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 10
阅读全文
摘要: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,
阅读全文
摘要:黑白染色模板题 首先通过DFS缩点,将所有相同状态的连通块缩成一个点 之后枚举每一个点进行BFS,计算变成最终状态的最小值 #include<bits/stdc++.h> using namespace std; const int N = 50, M = 2500; int T, n, m, cn
阅读全文
摘要:$f[A][B][C][D][X][Y]$表示当前由A张红桃,B张黑桃,C张梅花,D张方片,且小王的状态为X,大王的状态为Y的情况的期望的最小值 此时可以通过枚举每一个变量的状态得到状态转移 #include <bits/stdc++.h> using namespace std; const in
阅读全文
摘要:正推概率,逆推期望 $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
阅读全文
摘要:二分 + 前缀和 首先我们可以二分平均数 对于长度不小于L的子段, (1)等价于原数组中的每个数减去平均数,计算度不小于L的子段使得和大于0 (2)通过一个变量维护,$(0,i-L)$中前缀和的最小值 #include <bits/stdc++.h> using namespace std; con
阅读全文
摘要:AcWing 3164. 线性基 由高到低枚举二进制的每一位 通过高斯消元化为上三角矩阵 后将所有元素异或即可 #include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 10; in
阅读全文

浙公网安备 33010602011771号