02 2022 档案
摘要:带权并查集 #include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define LL long long using namespace st
阅读全文
摘要:题目等价于计算$M^{k^{N}} \ mod \ P$ 由费马小定理$M^{p-1} \equiv 1(mod \ P)$ 原式等于$M^{q(p-1)+r} mod \ P$其中$r=K^N mod(P-1)$ #include <bits/stdc++.h> #define IOS ios::
阅读全文
摘要:并查集 $p[i]$表示当前要插入的位置第一个可用位置 $a[i]$表示当前位置的值 #include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #d
阅读全文
摘要:#include <bits/stdc++.h> #define x first #define y second #define LL long long #define PII pair<int, int> using namespace std; const int N = 510; int
阅读全文
摘要:特判$X \geq 10^9$的情况 剩下情况暴力枚举 #include <bits/stdc++.h> #define LL long long using namespace std; LL n; int main() { scanf("%lld", &n); if (n >= 1e10) {
阅读全文
摘要:\[ 1 \ 2 \ 2 \ 5 \\ \ \ 1 \ 2 \ 2 \\ \ \ \ \ 1 \ 2 \\ \ \ \ \ \ \ 1 \\ \] 观察发现每一位只需要维护后缀和 #include <bits/stdc++.h> #define LL long long using namespac
阅读全文
摘要:A #include <bits/stdc++.h> using namespace std; char s[10]; void solve() { scanf("%s", s + 1); map<char, int> Map; bool flag = 1; for (int i = 1; i <=
阅读全文
摘要:A #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n; int a[N], b[N]; void solve() { cin >> n; for (int i = 1; i <= n; i ++ )
阅读全文
摘要:A #include <bits/stdc++.h> #define LL long long using namespace std; int T, n, m; void solve() { scanf("%d", &n); int res = 0; for (int i = 1; i <= n;
阅读全文
摘要:A #include <bits/stdc++.h> using namespace std; int main() { int a, b; scanf("%d%d", &a, &b); if (a > b) swap(a, b); if (b - a == 1 || b - a == 9) put
阅读全文
摘要:A #include <bits/stdc++.h> using namespace std; int main() { int x; scanf("%d", &x); printf("%.10lf\n", sqrt((12800000 + x)) * sqrt(x)); return 0; } B
阅读全文
摘要:A #include <bits/stdc++.h> #define LL long long using namespace std; const int N = 1e5 + 10; int n; int a[N]; void solve() { scanf("%d", &n); for (int
阅读全文
摘要:A class Solution { public: int countOperations(int num1, int num2) { int cnt = 0; while (num1 != 0 && num2 != 0) { if (num1 >= num2) num1 -= num2; els
阅读全文
摘要:动态开点只能开$Ofast$莽过去 #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; const int N = 15000010; int n, Q, root, cnt, L[N], R[N],
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; int n, m; int a[N]; struct Node { int l, r; int sum, lmax, rmax, tmax; }tr[N * 4
阅读全文
摘要:#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 10; int n, m; int w[N]; struct Node { int l, r; int tag, sum;
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n, m; int a[N]; struct Node { int l, r; int sum, lmax, rmax, tmax; }tr[N * 4
阅读全文
摘要:dfs序 + 状态压缩 + 线段树 #include <bits/stdc++.h> #define LL long long using namespace std; const int N = 4e5 + 10, M = N * 2; int n, m; int w[N], h[N], e[M]
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; int n, m; int a[N]; struct Node { int l, r; int lmax, rmax, tmax; /* lmax 表示从该区间
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; int n, m; int a[N]; struct Node { int l, r; int sum, lmax, rmax, tmax; //sum, //
阅读全文
摘要:二进制下的每一位用一个线段树维护,一共拆分成32棵线段树 #include <bits/stdc++.h> #define LL long long using namespace std; const int N = 1e5 + 10; int n, m; int a[N]; struct nod
阅读全文
摘要:https://atcoder.jp/contests/abc237/tasks/abc237_f 考虑用二分做最长上升子序列的数组的表示方法 \(f[i][j][k][l]表示从前i个选,长度为1的最长上升子序列中最小的数为j,长度为2的最长上升子序列中最后一个数最小的数为k,长度为3的最长上升子
阅读全文
摘要: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
阅读全文