03 2025 档案
摘要:#include <bits/stdc++.h> using namespace std; using ll=long long; const int N = 1e5 + 10; int aa[N]; ll a[N], pre[N], pre2[N], b[N],n, k, t; int check
阅读全文
摘要:解题的核心思路是通过二分查找来确定美味值最大的一段的最小值。 #include <iostream> #include <algorithm> using namespace std; #define int long long const int N = 2e5+10; int a[N],s[N]
阅读全文
摘要:P1182 数列分段 Section II 题目描述 对于给定的一个长度为 $N$ 的正整数数列 $A_{1\sim N}$,现要将其分成 $M$($M\leq N$)段,并要求每段连续,且每段和的最大值最小。 关于最大值最小: 例如一数列 $4\ 2\ 4\ 5\ 1$ 要分成 $3$ 段。 将其
阅读全文
摘要:关于最少尾数0的个数,只有2的倍数与5的倍数相乘才能得到0,显然2的倍数比5的倍数多的多,现在目标找5的倍数的个数 #include<bits/stdc++.h> #define endl "\n" #define int long long #define x first #define y se
阅读全文
摘要:一. 二分查找的基本逻辑 二分查找的核心思想是通过不断缩小搜索范围来找到目标值。通常有两种实现方式: 左闭右闭区间:[l, r]。 左闭右开区间:[l, r)。 二.while(l<r)和while(r-l>1) while (r - l > 1) 的作用 含义:当 l 和 r 相邻时(即 r -
阅读全文
摘要:思路: 统计每种数字的出现次数:遍历输入的数组,使用一个数组(例如 count)来记录每种数字(0 到 9)出现的次数。 计算目标次数:由于数组长度 n 是 10 的倍数,每种数字的目标出现次数为 target = n / 10。 分析数字的增减需求:对于每种数字,计算其出现次数与目标次数的差值。如
阅读全文
摘要:代码展示: #include<bits/stdc++.h> using namespace std; const int N=50010; #define x first #define y second typedef pair<int,int> PII; PII a[N]; int main()
阅读全文
摘要:魏蜀吴三国,各自的胜利是独立的,分别求出各国胜利所需的最大事件次数,最终求他们的最大值 代码: #include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e5 + 10; int a[N],
阅读全文
摘要:思路: 有的牛棚住牛,有的是空的,从反过来的思路来想,先用一块木板盖住所有有猪住的猪棚,减去空牛棚数,最终得到最多被木板挡住门的牛棚的数量。 代码展示: #include<bits/stdc++.h> using namespace std; const int N=210; int m,s,c;i
阅读全文