随笔分类 - Codeforces
摘要:F. Yamakasi 题目: F. Yamakasi 思路: 题目问和为 s 且区间最大值为 x 的区间数量,不难想到以 x 为遍历的主角,以两边不超过 x 的范围为边界,在这个范围里去下手。找边界(左右两边第一个大于/大于等于 x 的位置)为单调栈模板。 预处理好每个 x 的范围后,对于合法范围
阅读全文
摘要:C. Divine Tree 思路: 构造题,每个人方法都不一定一样。我的方法思路如下: 首先确定上下界:下届为 n,即全 1;上届为前 n 项和,等效于以 n 为根,连接其余点; 然后可以确定根结点一定是最大的那个 d(v),这个也好想。比如 \[13 = 1 + 2 + 3 + 4 + 3 \]
阅读全文
摘要:C – Coloring Game 思路: 不难看出,当 Alice 选完三个数 a b c(其中 a ≤ b ≤ c)后,Bob 能选的只有两种情况: 选择 c,这样只用比较 a+b 和 c 的大小关系,其中 a+b 一定要大于c; 选择数组最大值 a[n],这样只用比较 a+b+c 和 a[n]
阅读全文
摘要:A - New Generation ABC 思路:分段讨论 view code #include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<cstring> #include<cmath> #i
阅读全文
摘要:\(题意:定义f(i)为不能整除i的最小整数,求\displaystyle\sum_{i=1}^n f(i)\) 思路: 逐步筛掉因子,首先考虑f(i)=2的,肯定是奇数,也就是除了剩下的n/2个偶数,奇数部分已经可以不考虑了,而且贡献是2。 然后剩下了Left = n/2个数,这些数已经是2的倍数
阅读全文
摘要:A. Strange Table 签到题,算出对应行列即可。 view code #include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<cstring> #include<cmath> #i
阅读全文
摘要:A. Meximization 第i位优先放等于i-1的,没有的话就后面随便填了。 view code #include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<cstring> #includ
阅读全文
摘要:思路:A要赢的大前提就是当前x是一个波峰。 因为如果是一个直线单调的话如1 2 3 4 5(或者5 4 3 2 1),不管A选哪个位置,B直接在他下一个位置封死,A就直接GG。 现在考虑波峰的时候,那A就有两条路可以走,走左边或者走右边都可以(这个时候B就不能直接封死A了)。但是如果B能在别的地方挑
阅读全文
摘要:A. Anti-knapsack 思路:首先比k大的都可以加进来。其次对于小于k的,检验当前集合里面有没有和他相加等于k的,没有的话就可以加进集合。这一步可以覆盖多个数相加的情况。 view code #include<iostream> #include<string> #include<algo
阅读全文
摘要:A. ABC String 思路:相同字符要有相同的半括号(要么都是左括号要么都是右括号),总共8种情况。若把左括号看做1,右括号看成-1,那么这个序列满足任意前缀和\(sum[i]>=0且sum[n]==0\),对每种情况进行检验即可。 view code #include<iostream> #
阅读全文
摘要:A. K-th Largest Value 思路:操作就是0变1,1变0。那么只用统计1有多少个就知道第x大是谁了。 view code #include<iostream> #include<string> #include<algorithm> #include<cstdio> #include
阅读全文
摘要:A. Space Navigation 思路:分别统计往px和py方向的步数,看看能不能分别大于等于px和py。 view code #include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<c
阅读全文
摘要:久违的cf服务器爆炸场 A. Odd Divisor 思路:任何一个数都可以写成\(n = k2^m,其中k是一个奇数\),若k=1,那么n就一定是一个2的幂。 view code #include<iostream> #include<string> #include<algorithm> #in
阅读全文
摘要:A. Cards for Friends 思路:折纸游戏,看长宽能各折多少次,就是2的几次方,相乘即可。 view code #include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<cstri
阅读全文
摘要:A - Large Digits 思路:签到题,读入字符串即可。 view code #include<iostream> #include<string> #include<algorithm> #include<cstdio> #include<cstring> #include<cmath>
阅读全文

浙公网安备 33010602011771号