![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
cf
文章平均质量分 77
zsmj_sy
QQ 2439380624
展开
-
(复健)Codeforces Round #686 (Div. 3)个人题解
退役老狗复健ing,virtue了一下做了4题,前期做的太慢了,然后剩了40分钟吧,看的F,ST表那边写错了一个地方到死没debug出来= = 复健路漫漫啊A - Special Permutation就分奇偶,相邻两个交换一下就行,奇数最后三个交换int t;int n,m,a,b;int main(){ cin>>t; while(t--) { cin>>n; if(n%2==1) {原创 2020-12-03 20:13:44 · 182 阅读 · 0 评论 -
Codeforces Round #552 (Div. 3) E stl模拟 F dp G gcd
contest链接https://codeforces.com/contest/1154E题解思路直接哈希模拟删除T了,可以用setsetset和lowerlowerlower_boundboundbound函数减少寻找下一个没有删除元素的复杂度#include <bits/stdc++.h>using namespace std;#define IOS ios::syn...原创 2019-04-25 20:10:36 · 130 阅读 · 0 评论 -
CodeForces 1139D Steps to One(概率dp 容斥/莫比乌斯反演)
题目链接https://codeforces.com/contest/1139/problem/D题意:给定一个m,每次在1-m中随机取一个数放到容器中,当容器的gcd为1时停止,求期望步数,用分数形式的逆元输出题解思路:表示只会容斥的思路啊,反演的题解那步概率的转移没看懂= =(p/(1-p))哪个不知道怎么来的下面主要提一下容斥,以后有能力了补莫比乌斯反演的方法。...原创 2019-03-26 22:15:53 · 998 阅读 · 0 评论 -
codeforces#550 div3 G. Two Merged Sequences (贪心 / dp)
题意:从一个数组中提取出一个严格升序和一个严格降序的序列,可行输出方案题解思路:维护一个升序序列,一个降序序列,如果只满足其中一个,就插入,如果都不满足就输出no如果两个都满足,需要比较和下一个的大小关系:贪心思路就是尽量保持降序的最小值最大,保持升序的最大值最小很巧妙的贪心思路#include<bits/stdc++.h>using nam...原创 2019-04-03 21:28:56 · 118 阅读 · 0 评论 -
Codeforces Round #538 (Div. 2) D Flood Fill (区间dp)
题目链接:https://codeforces.com/contest/1114/problem/D题目大意:一个数组,ai表示i点的颜色,开始选一个点开始,每次可以将相同颜色的块全部变成另一种颜色,问最少花费的步数 最后要合成一个颜色相同的条。对区间 [ L , R ] 有两种转移方法:1.全部变成a[r+1]的颜色,如果当前颜色不同则需要+12.全部变成a[l-1]的颜色...原创 2019-03-12 20:41:12 · 163 阅读 · 0 评论 -
Codeforces Round #542 E Wrong Answer
题目链接:https://codeforces.com/contest/1130/problem/E题目大意:求一个数组中最大的 (R-L+1)*sum(a[i]~a[j]) 题目给出了一种错误的求法,输入一个数x,使正确的的答案是错误的答案+x,构造出这样的a数组错误的解法就是一旦前缀和小于0了,就抛掉不要,由于是构造题,我们可以简化这个问题。假设这个数组只有第一项是负的...原创 2019-03-12 17:14:38 · 178 阅读 · 0 评论 -
杜教BM板子解决线性递推问题
https://codeforces.com/contest/1117/problem/D转自https://blog.csdn.net/qq_37632935/article/details/87889975这题中看到了一个30ms的神仙代码,嫖了个杜教BM的板子O(n)搞一下前面几百项,放进去。。。 nb#include<bits/stdc++.h>usin...转载 2019-02-24 14:51:27 · 412 阅读 · 0 评论 -
Codeforces round #525 A-D题解报告
A 特判1,其他情况直接输出 x x 完美符合#include <cstdio>#include <cmath>#include <iostream>#include <vector>#include <algorithm>#include <stack>#include <cstring>#原创 2018-12-06 01:29:19 · 115 阅读 · 0 评论 -
Educational Codeforces Round 55 (Rated for Div. 2) A-D题解报告
A题:题意:从x到y翻书,每次只能翻d页,翻页的上下限为1和n,能翻到输出最小的步数,不能输出-1#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>#include <iomanip&...原创 2018-11-30 19:57:46 · 118 阅读 · 0 评论 -
Codeforces Round #524 (Div. 2) A-D题解报告
A 向上取整即可#include <cstdio>#include <cmath>#include <iostream>#include <vector>#include <algorithm>#include <stack>#include <cstring>#define MP make_原创 2018-12-04 21:50:54 · 155 阅读 · 0 评论 -
Codeforces Round #411 (Div. 2) 题解 总结(未完待续)
智商题专项训练2333333A - Fake NP CodeForces - 805ATavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.You are given l and r. For a...原创 2018-05-27 16:15:44 · 283 阅读 · 0 评论 -
Codeforces Round #470ABC 题解
A - Protect Sheep CodeForces - 948A (暴力)水题不贴代码了,暴力判断羊的相邻的四个点有没有狼,如果没有的话暴力把所有空的点填上狗- -B - Primal Sport CodeForces - 948B (数学)Alice and Bob begin their day with a quick game. They first choose a startin...原创 2018-04-27 21:56:31 · 350 阅读 · 0 评论 -
C - The Intriguing Obsession CodeForces - 869C 题解( 数学/dp )
C - The Intriguing Obsession CodeForces - 869C — This is not playing but duty as allies of justice, Nii-chan!— Not allies but justice itself, Onii-chan!With hands joined, go everywhere at a sp原创 2018-04-13 21:34:54 · 342 阅读 · 0 评论 -
CF Round #423 Div. 2 题解 总结
B - Black Square CodeForces - 828BPolycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Po...原创 2018-04-08 20:32:05 · 308 阅读 · 0 评论