思维
_WAWA鱼_
郑州大学退役ACMer,已签约小米浏览器内核开发,曾在科大讯飞实习做大模型SDK,努力成长中,欢迎大家一起学习和交流~
展开
-
B、价值序列---思维
价值序列—思维 数值的山峰和山谷是不能动的,其它位置的可选可不选 我们把相同的数看作一个整体 #include <iostream> #include <cstring> #include <algorithm> #include <vector> using namespace std; typedef pair<int,int>PII; #define int long long const int N =100010,mod=99824435原创 2022-02-12 20:44:42 · 111 阅读 · 0 评论 -
codeforce C.Strange Test和 acwing 两种操作
C.Strange Test—贪心+位运算 题解: ``首先我们要知道,a|b必然是大于等于b的,所以 #include <iostream> using namespace std; signed main() { int T; int a,b; cin>>T; while(T--) { scanf("%d %d",&a,&b); int res=b-a; for(int i=a;i<=b;i原创 2022-02-12 20:16:26 · 221 阅读 · 0 评论 -
Codeforces Round #767 (Div. 2) C. Meximum Array---思维
#include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 200010; int a[N]; int cnt[N],f[N]; int res[N],idx=0; int main() { int T; cin>>T; while(T--) { int idx=0; int .原创 2022-01-23 21:53:30 · 166 阅读 · 0 评论 -
Acwing第35场周赛T3三元组----多种解法
难得AK一次,看看大佬T3题解,发现可以有多种解法 解法一:直接暴力 #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 3010,INF = 0x3f3f3f3f; int a[N],b[N]; int n; int main() { scanf("%d", &n); for(int i=0;i<n原创 2022-01-22 21:27:37 · 316 阅读 · 0 评论 -
小岛问题、非零段划分----差分+思维
1.非零段划分—差分灵活运用 题目链接 题意: 每次使所有大于0的区间减去一个数,这个数任意,求这个过程中左右两边都是0的最大区间数。 思路: 区间减去一个数,理所应当想到差分,但是我们需要统计符合要求的区间的个数。 正常的差分是x坐标轴上的差分,这个题是差分高度,即差分y轴上的数值 在遇见两个不同高度时,这一段差值对答案贡献度为1,在插值区间上做差分,最后求最大值 #include <iostream> #include <cstring> #include <algor原创 2022-01-13 15:58:51 · 352 阅读 · 0 评论 -
01逆序对----数学公式推理
题目链接 思路: 有n个地方可以放数字, 我们考虑在n个位置中取两个位置i, j(i < j) 令 a[i] = 1, a[j] = 0, 形成全部逆序对, 然后其他位置任意放置, 计算每个逆序对在每个字符串中的贡献 于是得到总的方案是ans=2n−2∗(n2)=2n−3∗n∗(n+1) ans = 2^{n-2}* (\frac {n}{2})=2^{n-3}*n*(n+1)ans=2n−2∗(2n)=2n−3∗n∗(n+1), 证明上面的猜想是正确的 对了, 记得用快速乘! #include&l原创 2022-01-03 13:40:44 · 304 阅读 · 0 评论 -
求最值---数学+问题转化
玄学+问题转化 #include<iostream> #include<cstring> #include<algorithm> using namespace std; #define int long long const int N = 100010; int a[N]; int f(int x) { return x*x; } signed main() { int n; cin>>n; for(int i=1;i<原创 2022-01-03 11:51:31 · 52 阅读 · 0 评论 -
【每日一题】来写一道巧妙的题吧
写这道题的时候很久没想出来,立即求助于我的大佬朋友 行码棋,大佬给出解答,十分感谢 他的题解入口:链接 本题为软院招新赛题目,用内网才能看到,想看不再贴网址了 奕星的棋盘 描述 若世有神明 亦会胜他半子–奕星 奕星有一个2×N2×N2×N 的棋盘,奕星觉得自己的棋盘不够好看,想要把棋盘上的一部分白棋子替换成黑棋子,使得所有黑色棋子之间都可以联通,其中两个棋子斜着摆放不算是相连。 奕星想知道至少要将多少个白棋子替换成黑棋子。 注意:不能将黑棋子替换成白棋子。 输入 第一行有一个正整数 N ,(1<= N原创 2021-10-15 13:45:20 · 74 阅读 · 0 评论