随笔分类 -  前缀和、差分

摘要:题目链接:https://ac.nowcoder.com/acm/problem/16722 差分模版 #include <bits/stdc++.h> using namespace std; #define ll long long ll sum[1000005]; ll a[1000005]; 阅读全文
posted @ 2023-02-26 10:04 TFLSNOI 阅读(225) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://www.luogu.com.cn/problem/P5638 前缀和模拟 #include<bits/stdc++.h> using namespace std; const int max_n=1e6+10; int n, k; long long a[max_n]; l 阅读全文
posted @ 2023-02-23 08:59 TFLSNOI 阅读(25) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://www.luogu.com.cn/problem/P1387 二维前缀和模版题 #include<bits/stdc++.h> using namespace std; int n, m, a[105][105], s[105][105]; int ans; int mai 阅读全文
posted @ 2023-02-19 22:40 TFLSNOI 阅读(15) 评论(0) 推荐(0) 编辑
摘要:题目链接:https://www.luogu.com.cn/problem/P8649 方法一:模拟暴力(20分) #include<bits/stdc++.h> using namespace std; const int max_n=100010; int n, k, a[max_n]; lon 阅读全文
posted @ 2023-02-13 10:12 TFLSNOI 阅读(99) 评论(0) 推荐(0) 编辑
摘要:最大の和 #include<bits/stdc++.h> using namespace std; int n, k; int a[100010]; long long per_sum[100010], ans; int main() { cin>>n>>k; for(int i=1; i<=n; 阅读全文
posted @ 2023-02-11 11:08 TFLSNOI 阅读(19) 评论(0) 推荐(0) 编辑
摘要:[例题]一维前缀和 #include<bits/stdc++.h> using namespace std; int n, m; int a[100010]; long long per_sum[100010]; int l, r; int main() { cin>>n>>m; for(int i 阅读全文
posted @ 2023-02-11 10:47 TFLSNOI 阅读(29) 评论(0) 推荐(0) 编辑
摘要:U69096 前缀和的逆 #include<bits/stdc++.h> using namespace std; int n, a[10010]; int main() { cin>>n; for(int i=1; i<=n; i++)cin>>a[i]; for(int i=1; i<=n; i 阅读全文
posted @ 2023-02-11 09:55 TFLSNOI 阅读(31) 评论(0) 推荐(0) 编辑
摘要:题目链接 方法一:纯模拟50分 #include<bits/stdc++.h> using namespace std; int n, m; int a[100010]; int l, r; int ans; int main() { cin>>n; for(int i=1; i<=n; i++)c 阅读全文
posted @ 2023-02-11 09:37 TFLSNOI 阅读(123) 评论(0) 推荐(0) 编辑
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1282 方法一:暴力(40分) 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, a[105][105], ans=-(1<<30), s 阅读全文
posted @ 2021-05-12 10:34 TFLSNOI 阅读(545) 评论(0) 推荐(0) 编辑
摘要:题目链接https://www.luogu.com.cn/problem/P1083 一、5分题解: 1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 cout<<0; 6 return 0; 7 } View C 阅读全文
posted @ 2020-10-23 00:05 TFLSNOI 阅读(99) 评论(0) 推荐(0) 编辑
摘要:题目链接https://www.luogu.com.cn/problem/P3406 【解题思路】前缀和、查分 对于其中一小段,我们要么全部买纸票,要么全部刷卡。 所以我们只需要统计每一小段经过的总次数。 如果你暴力模拟统计的话,估计会tle。 怎么快速知道每一段次数呢? 我们回忆一下“借教室”这道 阅读全文
posted @ 2020-10-21 09:16 TFLSNOI 阅读(137) 评论(0) 推荐(0) 编辑
摘要:题目链接https://www.luogu.com.cn/problem/P3397 题目数据很水,但是差分的模版题 方法一:模拟 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m; 4 int sx, sy, ex, ey; 5 阅读全文
posted @ 2020-10-20 09:51 TFLSNOI 阅读(115) 评论(0) 推荐(0) 编辑
摘要:【问题描述】 给出一个n*m的矩阵,多次询问子矩阵中数字之和。 【输入格式】 第一行包含三个正整数n, m, k(n, m<=5000, k<=10000),分别表示矩阵行数和列数以及询问次数。 接下来的n行,每行包含m个整数(整数不超过10000),描述该矩阵。 接下来的k行询问,数据描述子矩阵左 阅读全文
posted @ 2020-10-15 16:44 TFLSNOI 阅读(1150) 评论(0) 推荐(0) 编辑
摘要:链接:https://www.luogu.com.cn/problem/P1115 方法一:0分代码 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, a[210000]; 4 int ans=-(1<<30); 5 int sum( 阅读全文
posted @ 2020-10-15 16:25 TFLSNOI 阅读(174) 评论(0) 推荐(1) 编辑
摘要:解决子数组问题 二维前缀和详解 前缀和、二维前缀和与差分的小总结 前缀和 和 差分模版 》》图示 二维前缀和练习 阅读全文
posted @ 2019-09-10 09:37 TFLSNOI 阅读(210) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示