随笔分类 - acm
摘要:#include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" using namespace std; typedef long long LL; co
阅读全文
摘要:状态表示$f[i][j][l][sum]$ 从前$i$个选,且第$i$个数为$j$,加上j后的递减序列的长度为$l$,以及当前所有数的总和为$sum$的方案数 状态转移 \[ if (j >= k) \quad f[i][j][1][sum + j] = (f[i][j][1][sum + j] +
阅读全文
摘要:#include <bits/stdc++.h> #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define IT set<node>::iterator using namespac
阅读全文
摘要:#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 std; con
阅读全文
摘要:带权并查集 #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 ++ )
阅读全文