随笔分类 - 洛谷
洛谷中出现的知识总结、题解等
摘要:题目传送门 //P1009.cpp #include <bits/stdc++.h> using namespace std; //本题有坑,使用长整也过不了洛谷的用例,因为它的用例是22,需要高精度,也就是乘法高精度+加法高精度 typedef long long LL; int n; LL re
阅读全文
摘要:题目传送门 //P1303.cpp #include <bits/stdc++.h> using namespace std; /** * 功能:高精度乘低精度模板 * @param A * @param b * @return */ vector<int> mul(vector<int> &A,
阅读全文
摘要:题目传送门 //P1601.cpp #include <bits/stdc++.h> using namespace std; /** * 功能:高精度加法模板 * @param A * @param B * @return */ vector<int> add(vector<int> &A, ve
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; int n, m; const int N = 1e5 + 10; struct Node { int dir; //方向,0:圈内,1:圈外 string name;//姓名 } c[N]; i
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 110; char a[N][N]; int dx[] = {0, 0, -1, 1, -1, 1, -1, 1}; //上下左右,左上,右上,左下,右下 int dy
阅读全文
摘要:题目传送门 //P1042.cpp #include <bits/stdc++.h> using namespace std; //每行至多 25 个字母,最多有 2500 行。 const int N = 25 * 2500 + 10; int a[N];//小华的输赢状态表 int idx; i
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 1e6; struct Student { string name; int age, score; } a[N]; int main() { int n; cin >
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; typedef long long LL; int n; /** 思路分析: 1、比如第10天桃子数量为1,我们记为s10=1. 2、那么我们可以考虑s9是多少? 3、第9天时,吃掉了s9的一半,
阅读全文
摘要:题目传送门 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 110; LL a[N]; int n; LL res; int main() { //录入进来,终止条件是CTRL+D wh
阅读全文
摘要:题目传送门 一、原始暴力法 #include<bits/stdc++.h> using namespace std; const int N = 100000010; //判断一个数是不是质数 bool isPrime(int n) { if (n < 2) return false; for (i
阅读全文
摘要:题目传送门 一、暴力解法 #include <bits/stdc++.h> using namespace std; bool isPrime(int n) { for (int i = 2; i <= n / i; i++) if (n % i == 0) return false; return
阅读全文
摘要:题目传送门 一、原始解法 #include <bits/stdc++.h> using namespace std; //判断一个数是不是质数 bool isPrime(int n) { if (n < 2) return false; for (int i = 2; i <= n / i; i++
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 1010; struct node { int id;//学号 double sc1, sc2;//学业成绩和素质拓展成绩 int score;//学业成绩和素质拓展成
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 1100; struct Student { string name; int x; int y; int z; int sum; } a[N]; int n; voi
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; struct Student { string Name; int chinese; int math; int english; } a, ans; int main() { int n; ci
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 1100; int a[N][N]; /**递归经典题 1、默认二维数组全是0,可以理解为默认都被赦免,如果找到不被赦免的,需要标识为1. 2、看到2^n之类的题,一般
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; int f(int n) { if (n == 1) return 1; return n * f(n - 1); } int main() { int n; cin >> n; cout <<
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 110; int n, m; int a[N]; double Max = -1; int main() { cin >> n >> m; for (int i = 1
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; //是不是闰年 bool isRunYear(int y) { if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0) return true; ret
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 110; int a[N]; bool isPrime(int n) { if (n < 2) return false; for (int i = 2; i <= n
阅读全文