随笔分类 - 洛谷
洛谷中出现的知识总结、题解等
摘要:题目传送门 //P3383.cpp #include <bits/stdc++.h> using namespace std; const int N = 1e8 + 10; //欧拉筛 int primes[N], cnt; // primes[]存储所有素数 bool st[N]; // st[
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; //2^7是极大值,就是 128是队伍的最大值,完全二叉树的最底层是128,上面肯定是127个,加在一起是255个,声明一个大于255的数字N可以保存的下 const int N = 260; i
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; stack<char> s; int num; /** 测试用例: 2 [({})] ()[]() */ char trans(char a) { if (a == ')') return '('; if (
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; typedef long long LL; int n, q, cmd, i, j, k; int main() { cin >> n >> q; vector<vector<int> > loc
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; int n, m, tmp; vector<int> stu; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) { cin >>
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int M = 1e6 + 10; int m, n, k;//m表示学校数,n表示学生 int a[M]; long long res;
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5010; int n, s; //苹果数 n,力气 s int a, b; //椅子的高度a,陶陶手伸直的最大长度b。 s
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 25; typedef long long LL; LL f[N][N][N]; LL w(LL a, LL b, LL c) { //注意判断的顺序,防止数组下标越界
阅读全文
摘要:题目传送门 一、深度优先搜索 #include <bits/stdc++.h> using namespace std; int n; //毫不意外,只通过了5个测试点,TLE了15个点~ int dfs(int x) { //1就没法继续分了,同时,由于题目说:原数列不做任何修改就直接统计为一种合
阅读全文
摘要:题目传送门 一、递推+高精度 #include <bits/stdc++.h> using namespace std; const int N = 5010; /** * 功能:高精度加法模板 * @param A * @param B * @return */ vector<int> add(v
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; double k; double x; int main() { cin >> k; for (int cnt = 1;; cnt++) { x += 2.0 * pow(0.98, cnt -
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; typedef long long LL; const LL MOD = 1e9 + 7;//要模的质数 const int N = 1e5 + 10; int a[N]; //木棍长度数组,木棍
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 10; //数字0-9需要的火柴个数,这个字典妙啊~,成为解决火柴棍难题的关键~ int a[N] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 110; char a[N][N]; //以i,j为坐标的点,向右找k个,看看是不是都是空地;向下找k个,看看是不是都是空地 int check(int i, int
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 110; char a[N][N]; int MIN = 0x3f3f3f3f; int n, m; /** * 功能:计算在白x行,蓝y行,红z行的情况下,修改的数量
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; int a[10]; int main() { int n; cin >> n; //放入数组 for (int i = 1; i <= n; i++) a[i] = i; do { //输出打印
阅读全文
摘要:题目传送门 一、暴力大模拟 #include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; bool found = false; for (int i1 = 1; i1 <= 9
阅读全文
摘要:题目传送门 一、无脑大循环 #include<bits/stdc++.h> using namespace std; vector<string> v1; int main() { int a, b, c, d, e, f, g, h, i, j, k, l = 0; cin >> k; for (
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 30; string a[N]; bool cmp(const string &a, const string &b) { //自定义排序函数,这一步非常巧妙,假设a=
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 110; struct Student { string Name; int year, month, day, num; } a[N]; bool cmp(const
阅读全文