
算法
李自行h
这个作者很懒,什么都没留下…
展开
-
Bubble Cup 13 - Finals [Online Mirror, unrated, Div. 1]K. Lonely Numbers【打表+线性筛模板+前缀和】
题目传送门In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.More precisely, two different numbers a and b are friends if gcd(a,b), agcd(a,b), bgcd(a,b) can form sides of a triangle.Three numb原创 2020-10-17 20:01:05 · 288 阅读 · 0 评论 -
Codeforces Round #674 (Div. 3)D. Non-zero Segments【前缀和+思维】
题目传送门Kolya got an integer array a1,a2,…,an. The array can contain both positive and negative integers, but Kolya doesn’t like 0, so the array doesn’t contain any zeros.Kolya doesn’t like that the sum of some subsegments of his array can be 0. The subseg原创 2020-10-16 20:40:43 · 174 阅读 · 0 评论 -
Bubble Cup 13 - Finals [Online Mirror, unrated, Div. 2]G. Years【差分+优先队列】
题目传送门G. Yearstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputDuring one of the space missions, humans have found an evidence of previous life at one of the planets. They were lucky enough to find原创 2020-10-12 20:20:06 · 611 阅读 · 0 评论 -
HDU - 6273Master of GCD【一维差分】
题目Problem J. Master of GCDHakase has n numbers in a line. At first, they are all equal to 1. Besides, Hakase is interested inprimes. She will choose a continuous subsequence [l, r] and a prime parameter x each time and forevery l ≤ i ≤ r, she will chan原创 2020-10-08 21:20:42 · 149 阅读 · 0 评论 -
A. Arena of Greed【贪心+特判】
题目传送门inputCopy256outputCopy24题意:T组测试样例,每组一个数n,有n个物品,两个人轮流拿操作,有以下两种操作1:拿一个物品2:当n为偶数时拿一半物品.问:第一个人先手,最多可以得到多少物品思路:第一种操作不会有什么问题,对于第二种操作我们有两种选择,1拿一个,2拿一半,,他们应该尽可能保证在另一个人拿一个的情况下自己拿一半,例如12,如果我们不判断上面的条件直接拿一半的话,第一个人:6 1 1,第二个人:3 1;但是我们用上面的条件判断后第一原创 2020-10-05 16:44:28 · 419 阅读 · 0 评论 -
Gym - 101875II Will Go【模板dfs序】
推荐一波大佬讲解dfs序和欧拉序非常详细https://www.cnblogs.com/stxy-ferryman/p/7741970.html题目传送门Input3 21 2 -10 22 0OutputYesNo题意:给出两个数n,m,下面是n个人的好朋友,如果为-1的话表示他没有好朋友,他的好朋友去了他一定去,这个人去了的话他的好朋友不一定去.下面是m个询问,问x去了y会去吗?思路:我们只要判断y是否为x的祖先即可,在dfs序中我们以没有好朋友的人分别为根建树然.原创 2020-10-04 10:11:33 · 350 阅读 · 0 评论 -
Gym - 101875L PC is for kicking【bfs】
参考大佬的博客写的很好https://blog.youkuaiyun.com/gtgym321/article/details/90145411题目传送门Input5 21 21 32 53 4Output4题意:给出两个数n,m,下面是n-1行,每行有两个数表示连通,从m点开始走最多能走过几个点(不能重复)思路bfs遍历AC code#include<iostream>#include<algorithm>#include<cstring.原创 2020-10-02 21:49:31 · 919 阅读 · 0 评论 -
Gym - 101875BUgly Number【最小表示法模板题】
题目传送门Input3123OutputYesInput42214OutputNo题意:给出一个数n再给出一个字符串,求这个串是否为他的最小同构字符串,是的话输出Yes否则输出No思路:模板题,直接套最小表示法的模板#include<iostream>#include<algorithm>#include<cstring>#include<cmath>#include<map>#include&l原创 2020-10-02 21:07:39 · 129 阅读 · 0 评论 -
Gym - 101911B Glider【尺取】
参考大佬的博客https://blog.youkuaiyun.com/mmk27_word/article/details/85063325?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522160153852919724835851673%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=160153852919724835851.原创 2020-10-01 18:57:06 · 164 阅读 · 0 评论 -
Educational Codeforces Round 95 (Rated for Div. 2)C. Mortal Kombat Tower【dp】
传送门题目输入681 0 1 1 0 1 1 151 1 1 1 071 1 1 1 0 0 161 1 1 1 1 11110输出222210题意:t组测试样例,给你一个数n,下面紧接着给你n个数,由0到1组成,如果为1则说明此boss较难,0则较简单,你的朋友每通过一个较难的boss时需使用一个跳跃点,你的朋友先手每次能杀死1或2个boss紧接着是你一直到n个boss杀完,问:至少需要多少个跳跃点.思路:dp模板题,每人每次有两个选择,即上个人原创 2020-09-24 20:16:31 · 351 阅读 · 0 评论 -
CodeForces - 377A Maze【dfs+思维】
传送门题意题意,给出n,m,k,三个长度,n,m,分别为地图的长宽,地图中有墙壁‘#’和空位置‘.’想把k个空位置变成墙壁(用x表示)使‘.’还为一个连通区域思路想在‘.’中选择k个位置变成墙壁使剩下的点保持连通,那我们是不是可以反过来想呢?我们先让所有点的位置变为X再用一个dfs找出要剩下的几个点这样他们肯定连通,问题得以解决.AC 代码#include<iostream>#include<algorithm>#include<cstring>原创 2020-09-20 08:22:45 · 142 阅读 · 0 评论