随笔分类 - 洛谷
洛谷中出现的知识总结、题解等
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; double dis(double x1, double y1, double x2, double y2) { return sqrt((x2 - x1) * (x2 - x1) + (y2 -
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; int a[3]; char s1, s2; int main() { //充分利用c++语言优势 while (scanf("%c:=%c;", &s1, &s2) == 2) //赋值语句简洁
阅读全文
摘要:题目传送门 #include<bits/stdc++.h> using namespace std; string a; string b; int main() { cin >> a >> b; int sum1 = 1; for (int i = 0; i < a.size(); i++) su
阅读全文
摘要:题目传送门 #include<bits/stdc++.h> using namespace std; //原始英文数字 // You are a three eight pig . 10964 unordered_map<string, int> _map = {{"zero", 0}, {"one
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; const int N = 25; int a[N][N][N]; int main() { int w, x, h, q; cin >> w >> x >> h >> q; int x1, y1, z1,
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; const int N = 1010; int a[N][5];//二维的最后一个位置,装总分 int n; int cnt; int main() { cin >> n; for (int i = 1; i
阅读全文
摘要:重点: 用数组记数,大于的就表示被移走了,等于的没动过。 #include <bits/stdc++.h> using namespace std; const int N = 10010; int b[N]; int l; int m; //区域的数目 int u, v; //表示一个
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; const int N = 210; int a[N], cnt; int n; int main() { cin >> n; while (n > 1) { a[cnt++] = n; if (n % 2
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; const int N = 110; int a[N]; int main() { int idx; //数字0时终止输入 for (idx = 0;; idx++) { cin >> a[idx
阅读全文
摘要:题目传送门 重点: 使用数组为每条小鱼记数。 #include <bits/stdc++.h> using namespace std; const int N = 110; int a[N], b[N], n; int main() { cin >> n; //每一条小鱼的可爱值 for (int
阅读全文
摘要:第一部分 语言入门 第一章 简简单单写程序 例 1-11 评测机队列 第二章 顺序结构程序设计 例题 P5703 红 例5 P5704 红 例6 P5705 红 例71 P5706 红 例8 P1425 红 例10 P3954 红 例11(NOIP 2017 PJ T1) P5707 橙 例12 习
阅读全文
摘要:奶牛的发型 题目传送门 一、理解和感悟 1、号码和值都是非常重要的,不要只记录值,用一个数组来保存值,号码就是。 2、每头牛都是在找到了右侧比自己高的牛时,记录右侧第一个比自己高的牛。 3、最终统计时有两种情况,一种是找到了右侧比自己高的牛,另一种是没有找到右侧比自己高的牛。 4、
阅读全文
摘要:题目传送门 一、解题思路 1、又能向左发射,又能向右发射,不太好想。复杂问题都是由简单问题组装而来,我们先来考虑这个问题的一半。假如每个发射站只会向左发射信号,如果第个发射塔比它左边的发射站都高,那么第个发射站左边的站点就不可能收到站点及站后面所有站点发送来的信号,因为就算有
阅读全文
摘要:AcWing题目传送门 洛谷题目传送门 一、题目描述 约翰有头奶牛,编号为到。 现在这头奶牛按编号从小到大的顺序站成了一排,其中奶牛 的身高为。 现在,每头奶牛都向它的右侧望向那些编号较大的奶牛,对于奶牛 如果存在一头奶牛 满足
阅读全文
摘要:题目传送门 一、前导知识 欧拉函数与筛法求欧拉函数 二、朴素思路 我们先不管数据范围是不是,先思考就朴素的作法是什么样的: ,假设在我们可控的数据范围内,就是筛出数据范围内的, 然后利用公式计算一下和,再$mo
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; typedef long long LL; LL x, y, ans; //辗转相除法 LL gcd(LL a, LL b) { if (b == 0) return a; ans += 4 *
阅读全文
摘要:题目传送门 一、解题思路 这道题有些意思,因为肯定是分子,怎么想办法也不可能变成分母。肯定是分母,怎么的也变不成分子。就是有可能是分子,也有可能是分母,尽量想办法让它们全是分子,这样出现整数的概率高,出现在分母,还得想办法去约分掉它,麻烦。(贪心) 那它们是否真的
阅读全文
摘要:题目传送门 一、准备知识 求一个数x的所有约数 #include <bits/stdc++.h> using namespace std; const int N = 1010; int c[N]; /** * 功能:获取指定数x的所有约数 * @param x */ void ys(int x)
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; typedef long long LL; LL a, b, c; LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; } LL lcm(LL x
阅读全文
摘要:题目传送门 #include <bits/stdc++.h> using namespace std; int a, b, c, d; /** 测试用例: 2/1+1/3-1/4 答案:25/12 -2/1+1/3-1/4 答案:-23/12 测试点6 7/4+1/3+8/5-3/2-6/9-6/4
阅读全文