E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
#Codeforces
codeforce 3B. Lorry(贪心)
题目:http://
codeforces
.com/problemset/problem/3/B大意是,给定N和V,在给出N个vehicle的类型号(1或2)和各自的载重量,求在不超过V的情况下最大的载重值及其分配方案
theArcticOcean
·
2020-09-14 20:17
algorithm_贪心
cf Educational
Codeforces
Round 45 D. Graph And Its Complement
原题:D.GraphAndItsComplementtimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputGiventhreenumbersn,a,b.Youneedtofindanadjacencymatrixofsuchanundirectedgraphthatth
红鲤鱼遇绿鲤鱼
·
2020-09-14 20:47
图论
cf
cf Educational
Codeforces
Round 81 E. Permutation Separation
原题:E.PermutationSeparationtimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputYouaregivenapermutationp1,p2,…,pn(anarraywhereeachintegerfrom1tonappearsexactlyonc
红鲤鱼遇绿鲤鱼
·
2020-09-14 20:47
根本不会/就差一点/记得再看
数据结构
cf Educational
Codeforces
Round 81 D. Same GCDs
原题:D.SameGCDstimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputYouaregiventwointegersaandm.Calculatethenumberofintegersxsuchthat0≤xusingnamespacestd;constintm
红鲤鱼遇绿鲤鱼
·
2020-09-14 20:46
数学
cf Educational
Codeforces
Round 81 C. Obtain The String
原题:C.ObtainTheStringtimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputYouaregiventwostringssandtconsistingoflowercaseLatinletters.Alsoyouhaveastringzwhichisini
红鲤鱼遇绿鲤鱼
·
2020-09-14 20:46
二分/三分
Count Pairs
CodeForces
- 1188B 推式子
Youaregivenaprimenumberpp,nnintegersa1,a2,…,ana1,a2,…,an,andanintegerkk.Findthenumberofpairsofindexes(i,j)(i,j)(1≤iusingnamespacestd;typedeflonglongll;constintmaxn=3e5+15;lla[maxn];mapmp;intmain(){lln
wind_bow
·
2020-09-14 20:40
数论
Zero Tree
CodeForces
- 275D
http://
codeforces
.com/problemset/problem/275/Dminn[i]代表以i为根的子树要变零树要减几次maxx[i]是加几次最后汇总至根节点输出maxx[1]-minn
sunyutian1998
·
2020-09-14 20:07
树型DP
树型DP
CodeForces
Kefa and Dishes
CodeForces
- 580D
http://
codeforces
.com/problemset/problem/580/D状压DP裸题dp[i][j]代表状态i下以第j道菜为结尾时的最大满意度当某一状态恰好有m道菜时更新一下答案即可
sunyutian1998
·
2020-09-14 20:07
状压DP
CodeForces
状压DP
【
Codeforces
Round 263 (Div 2)B】【水题 贪心】Appleman and Card Game 选字符,每个字符个数的平方
ApplemanandCardGametimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputApplemanhasncards.Eachcardhasanuppercaseletterwrittenonit.ToastmanmustchoosekcardsfromAppl
snowy_smile
·
2020-09-14 20:20
题库-CF
CodeForces
水题
贪心
【
Codeforces
Round 335 (Div 2) C】【贪心 脑洞 有趣排序】Sorting Railway Cars 全排列排序可以提前后提后的最小操作数
C.SortingRailwayCarstimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputAninfinitelylongrailwayhasatrainconsistingofncars,numberedfrom1ton(thenumbersofallthecar
snowy_smile
·
2020-09-14 20:50
题库-CF
CodeForces
贪心
脑洞
构造
有趣排序
【
Codeforces
Round 323 (Div 2)B】【贪心】Robot's Task 最少转弯次数拿走所有物品
B.Robot'sTasktimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputRobotDocislocatedinthehall,withncomputersstandinaline,numberedfromlefttorightfrom1ton.Eachcomput
snowy_smile
·
2020-09-14 20:50
贪心
题库-CF
CodeForces
CodeForces
- 803C(GCD+思维)
MaximalGCD题目传送门题意:给你两个数n,k。要你找一个严格连续递增数列,要求序列有k个元素,和为n并且gcd最大。思路:很容易知道,要使得gcd最大,那么最大公约数必为数列首项,所以其最大公约数一定是n的因子。最好的情况为1d,2d,3d……,kd(d为最大公约数),即有k*(k+1)/2个d。因此,我们只需要求出n的因子,找到小于等于n/k*(k+1)/2中最大的因子就是最优的d,然后
siyutt
·
2020-09-14 20:15
思维
Codeforces
570B Simple Game 概率求解,简单数学思维
题目描述了这么一个情景,给定一个范围1~n,两个人(简记为a和b)各自随机选一个整数,然后再在1~n这个范围内随机找一个整数(1~n所有整数被选到的概率是相等的),这两个人谁选择的数更接近这个随机数谁就赢。现在给出选数范围,给出其中一方(记做b)已经选好的数(记做m),问a应该选哪个数,才能使得a获胜的几率尽可能大?如果有不唯一的答案,就输出其最小值画根数轴自己想象一下就明白了,如果b选好的数m更
skyword_sun
·
2020-09-14 20:15
简单数学
CodeForces
710B Optimal Point on a Line(首场完美被虐,安安睡吧+总结)
B.OptimalPointonaLinetimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputYouaregivennpointsonalinewiththeircoordinatesxi.Findthepointxsothesumofdistancestothegiv
Shyazhut
·
2020-09-14 20:37
CodeForces
小有趣的思维数学
CodeForces
670B Game of Robots(第k个出现的数字)
http://
codeforces
.com/problemset/problem/670/BB.GameofRobotstimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputInlateautumneveningnrobotsgatheredinthecheerfulco
Shyazhut
·
2020-09-14 20:37
小有趣的思维数学
CodeForces
Educational
Codeforces
Round 53 (Rated for Div. 2)C. Vasya and Robot(二分)
C.VasyaandRobotVasyahasgotarobotwhichissituatedonaninfiniteCartesianplane,initiallyinthecell(0,0)(0,0).Robotcanperformthefollowingfourkindsofoperations:U—movefrom(x,y)(x,y)to(x,y+1)(x,y+1);D—movefrom(
1naive1
·
2020-09-14 20:32
数学
思维题
Educational
Codeforces
Round 44 (Rated for Div. 2) C. Liebig's Barrels
C.Liebig'sBarrelsYouhavem = n·kwoodenstaves.Thei-thstavehaslengthai.Youhavetoassemblenbarrelsconsistingofkstaveseach,youcanuseanykstavestoconstructabarrel.Eachstavemustbelongtoexactlyonebarrel.Letvolu
1615925431
·
2020-09-14 20:23
Codeforces
Codeforce 719B
题目链接http://
codeforces
.com/problemset/problem/719/B思路不论输入什么,最终序列只有两种rbrbrb,brbrbr两种找输入串和最终序列错位的个数,这些错位数一定要花费一次
ukiy
·
2020-09-14 20:51
水题
Educational
Codeforces
30 B. Balanced Substring 前缀和&&思维
题意:给一个01串寻找一个最长字串,这个字串中的0和1数量相等思路:将0变成-1,求前缀和,两个位置前缀和大小相等,说明这之间的01数量相等注意!第0位的前缀和位0#include#includeusingnamespacestd;intsum[100010];chars[100010];mapq;intmain(){intn,ans=0;cin>>n>>s+1;for(inti=1;i<=n;i
samscream
·
2020-09-14 20:51
思维
前缀和
Educational
Codeforces
Round 48 (Rated for Div. 2) D. Vasya And The Matrix(构造)
描述NowVasyaistakinganexaminmathematics.Inordertogetagoodmark,Vasyaneedstoguessthematrixthattheteacherhasconstructed!Vasyaknowsthatthematrixconsistsofnrowsandmcolumns.Foreachrow,heknowsthexor(bitwiseexc
riba2534
·
2020-09-14 20:47
【Codeforces】
【思路
模拟
构造】
Codeforces
Round #512(Technocup 2019 Elimination Round 1) D. Vasya and Triangle (
Codeforces
1030D)
题目:VasyaandTriangle题意:给出三个数n,m,k,求是否存在第一象限的3个点满足每个点的横坐标小于等于n,纵坐标小于等于m,坐标为整数,且构成的三角形面积等于n*m/k。思路:不妨把这个三角形看做直角三角形,然后把它补全成长方形,面积为nm2/k。那么这个面积一定是整数,如果不是整数就输出NO。接下来先尽量最大化横坐标x,即求gcd(nm2/k,n),然后算出y,输出即可。代码:#
ZarOuaoan
·
2020-09-14 20:09
数学问题
最小路径树
Codeforces
545E Paths and Trees
传送门:点击打开链接题意:告诉你图,和起点,求一棵树,使得起点走树上的路径到达其他的节点的路径是原来图中的最短的,且要求起点到所有点的距离之和最短。思路:其实就是dijkstra的思路,只不过要稍微注意几个东西,首先是要保存上一条边的id,然后就是要注意当dist相同时,两条路径的长度相等时,应该要考虑最后一条边的长度,应该要选长度小的,因为两种方法实际上都是最短的,但是如果选边短的,就说路径上另
逍遥丶綦
·
2020-09-14 20:37
ACM_图论
前缀和
Codeforces
611C New Year and Domino
传送门:点击打开链接题意:告诉你一个地图(5e2*5e2),里面有障碍物,现在告诉你地图里面的一个子矩阵的对角点坐标,求这个子矩阵里能放多少个1*2的多米诺牌思路:求dp[i][j]表示(1,1)到(i,j)这个子矩阵的的答案,A[i][j]表示第i行的前j列的答案,b[i][j]表示第i列的前j行的答案那么对于(bx,by),(ex,ey),答案就等于dp[ex][ey]-dp[ex][by]-
逍遥丶綦
·
2020-09-14 20:37
ACM_前缀和
状压dp
Codeforces
580D Kefa and Dishes
思路:...只能说
Codeforces
的测评机实在是太好了,n=18,O(n^2*2^n)复杂度的记忆化搜索代码都能在500ms跑出来,我自己本地跑了3秒多--如果你敢写O(n^2*2^n)复杂度的代码的话
逍遥丶綦
·
2020-09-14 20:37
ACM_DP
Codeforces
Round #669 ABC 题解
我的博客园传送门,看起来方便点A.Ahahahahahahahaha题意:给个一个偶数长度的01序列,要求删除不超过2/n个元素使得奇数位和等于偶数位和。思路:注意到题目给的提示,只有0和1,且为偶数长度。那么对和有贡献的也就只有1,而且0或1总有一个出现次数小于等于n/2。所以我们就有这样的策略,把最后搞的只剩0或者1即可,0的个数小就删0,反之删1。最后注意只保留1的时候还要考虑一下答案数组长
追风者_
·
2020-09-14 20:00
codeforces
题解
codeforces
题解
669
Codeforces
1118F1-Tree Cutting (Easy Version) (树形dp入门题)
我们一起去砍树咔咔咔Youaregivenanundirectedtreeofnnvertices.Someverticesarecoloredblue,somearecoloredredandsomeareuncolored.Itisguaranteedthatthetreecontainsatleastoneredvertexandatleastonebluevertex.Youchoosea
From now on...
·
2020-09-14 20:59
搜索
树形dp
动态规划
树形dp
Codeforces
Round #168 (Div. 2) D题 Zero Tree
ZeroTreeAtreeisagraphwithnverticesandexactlyn - 1edges;thisgraphshouldmeetthefollowingcondition:thereexistsexactlyoneshortest(bynumberofedges)pathbetweenanypairofitsvertices.AsubtreeofatreeTisatreewit
不拿牌不改名
·
2020-09-14 20:54
#
树型dp
树形dp
Codeforces
Round #572 (Div. 2) Number Circle
Youaregivennnumbersa1,a2,…,an.Isitpossibletoarrangetheminacircleinsuchawaythateverynumberisstrictlylessthanthesumofitsneighbors?Forexample,forthearray[1,4,5,6,7,8],thearrangementontheleftisvalid,while
柠檬咕咕咕
·
2020-09-14 20:53
CodeForces
Codeforces
1353 D. Constructing the Array
题意:一个长度为nnn的数组,初始值全部为000每次选择其中最长的一段全000连续子数组,如果多个并列最长,取最左边的那个,并标记其左右区间LRLRLR如果这个子数组包含的元素个数为奇数(R−L+1R-L+1R−L+1为奇数),则将这一段区间最中间那个位置标记上数字如果这个子数组包含的元素个数为偶数,则将这一段区间内中间靠左的那个位置标记上数字数字依次标记1−n1-n1−n,最后输出这个数组。AC
邵光亮
·
2020-09-14 20:51
CodeForces
CodeForces
1266 C Diverse Matrix(GCD构造)
题意:给你rrr和ccc,让你构造出来一个r∗cr*cr∗c的矩阵,矩阵元素每一行的最大公因子和每一列的最大公因子不能相同,让你构造出来一个最大公因子最小的矩阵。显而易的我们构造的矩阵的公因子就是111到r+cr+cr+c这样才能保证最大公因子最小。就让行的公因子为1−r1-r1−r,列的公因子为r+1,r+cr+1,r+cr+1,r+c.AC代码:#include#include#include
邵光亮
·
2020-09-14 20:21
CodeForces
Codeforces
Round #661 (Div. 3) D. Binary String To Subsequences
Codeforces
Round#661(Div.3)D.BinaryStringToSubsequences题目链接Youaregivenabinarystringsconsistingofnzerosandones.Yourtaskistodividethegivenstringintotheminimumnumberofsubsequencesinsuchawaythateachcharact
旺 崽
·
2020-09-14 20:21
vector
思维
Codeforces
Codeforces
Round #650 (Div. 3) F1. Flying Sort (Easy Version)
题目链接题意:给你一个数组可以执行两种操作吧一个元素放到数组的最开头或者最末尾,问最少多少次操作可以让他升序。思路:我们看排好后的序列的子串在原始数组出现的最长长度就是他不用变的长度,答案就是n减去他。#include#include#include#include#include#includeusingnamespacestd;typedeflonglongll;#defineSISstd::
Ray.C.L
·
2020-09-14 20:49
CF
Codeforces
1303 E. Erase Subsequences(DP)
Description:Youaregivenastringsss.Youcanbuildnewstringpppfromsssusingthefollowingoperationnomorethantwotimes:chooseanysubsequencesi1,si2,…,siks_{i_{1}},s_{i_{2}},…,s_{i_{k}}si1,si2,…,sikwhere1≤i1#incl
邵光亮
·
2020-09-14 20:49
DP
Educational
Codeforces
Round 90 (Rated for Div. 2) C. Pluses and Minuses (1300)
C.PlusesandMinuses题意:给一个字符串s,有如下代码:res=0forinit=0toinfcur=initok=truefori=1to|s|res=res+1ifs[i]=='+'cur=cur+1elsecur=cur-1ifcur#defineintlonglongusingnamespacestd;constintN=2e5+10;signedmain(){ios::sy
狐佑 怜
·
2020-09-14 20:48
数学
题解
暴力
字符串
算法
CodeForces
- 719B
CodeForces
- 719A(思维+贪心)
题目:传送门思路:因为我们要保证颜色交错,那么给定我一个序列后,就只有两种可以满足条件的最终序列,即以’R’颜色开头和以‘B’颜色开头,所以我们把两种情况分别讨论一下,取最小值即可。在计算某种情况下需要的操作数时,如何第i位的颜色一样,我们当然最优考虑是不管它,如果不同,我们就统计不同时这个位置是R或是B的个数hr,hb。因为需要b的位置(这个位置上是R)有hr个,需要r的位置(这个位置上是B)有
JingLuoZZZ
·
2020-09-14 20:15
欧泡时间到
CodeForces
- 1118 F1 Tree Cutting (Easy Version)【DFS】
F1.TreeCutting(EasyVersion)timelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputYouaregivenanundirectedtreeofnnvertices.Someverticesarecoloredblue,somearecolored
kmlver
·
2020-09-14 20:09
【Choosing Capital for Treeland 】【
CodeForces
- 219D 】(树形dp)
题目:ThecountryTreelandconsistsofncities,somepairsofthemareconnectedwithunidirectionalroads.Overalltherearen - 1roadsinthecountry.Weknowthatifwedon'ttakethedirectionoftheroadsintoconsideration,wecangetf
洋-葱
·
2020-09-14 20:04
树形dp
CodeForces
- 1016D Vasya And The Matrix
题意:输入n,m表示一个n*m的矩阵输入n个数表示每行的异或和输入m个数表示每列的异或和如果能构造这样的矩阵输出YES并打印其中一个矩阵否则输出NO思路:首先YES的条件是所有行的异或和suma=所有列的异或和sumb=矩阵每个数的异或和我们由异或性质可得0异或任何一个数=他本身即0^a=a所以我们让每一列的最后一行数为他的列异或和其他都为0比如一个4*2矩阵的列异或和是4200000042同理我
everduo
·
2020-09-14 20:57
【题解】
codeforces
1047C[
Codeforces
Round #511 (Div. 2)]C.Enlarge GCD 最大公约数
DescriptionMr.Fhasnpositiveintegers,a1,a2,…,an.Hethinksthegreatestcommondivisoroftheseintegersistoosmall.Sohewantstoenlargeitbyremovingsomeoftheintegers.Butthisproblemistoosimpleforhim,sohedoesnotwant
不进清北不改名
·
2020-09-14 20:26
比赛
codeforces
最大公约数
【题解】
codeforces
1047A[
Codeforces
Round #511 (Div. 2)]A.Little C Loves 3 I 数学知识
题目链接DescriptionLittleClovesnumber«3»verymuch.Helovesallthingsaboutit.Nowhehasapositiveintegern.Hewantstosplitninto3positiveintegersa,b,c,suchthata+b+c=nandnoneofthe3integersisamultipleof3.Helphimtofin
不进清北不改名
·
2020-09-14 20:26
数学知识
比赛
codeforces
Codeforces
Round #518 (Div. 2) D. Array Without Local Maximums dp
题目链接:http://
codeforces
.com/contest/1068/problem/D题意:给你n个数,其中有一些数字被遗忘了(被遗忘的数输入位-1),但是知道所有的数满足:a1≤a2,an
余西子
·
2020-09-14 20:25
dp
思维
Codeforces
Round #548 (Div. 2)C. Edgy Trees(dfs,思维)
题解:总的全排列减去不符合的全排列,不符合的就是从一个点到另一个点的路径全部为红边(0),具体看代码,挺水的一个题。以下为代码#includeusingnamespacestd;#defineintlonglongconstintmaxn=1e5+5;constintmod=1e9+7;vectorve[maxn];boolv[maxn];intn,k;intnum=0;voiddfs(intx)
UUUUh
·
2020-09-14 20:52
Codeforces
codeforces
1016 D. Vasya And The Matrix(数学+思维)
D.VasyaAndTheMatrixtimelimitpertest2secondsmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputNowVasyaistakinganexaminmathematics.Inordertogetagoodmark,Vasyaneedstoguessthematrixthatt
JIA-YAO
·
2020-09-14 20:52
水题
数学
CodeForces
- 1169C(二分+思维)
CodeForces
-1169C1、思路:每次可以选取任意几个数字进行(ai+1)%m的操作,所以最多m次让序列变为非递减序列。让所有的元素值保持尽可能的小,能使最终的操作数最小。
WA掘机
·
2020-09-14 20:21
二分优化
codeforce
CodeForces
- 1247D Power Products【数论】
题目链接:https://
codeforces
.com/problemset/problem/1247/D题意:给你一个序列a,问有多少对i,j满足存在x使得ai*aj=x^k,k是给定的。
moomhxy
·
2020-09-14 20:47
数论
CF
Codeforces
580D Kefa and Dishes
看完题目还是一脸蒙,百度了半天,看了好几个AC代码才勉强写(凑)出来。题意很简单,菜单上有n道菜,你可以点m样,每样菜有它自己的幸福感,然后还加入了k个规则,比如在吃了第i样菜之后,再吃第j样菜,可以获得c的幸福感,问最大的幸福感。1usingnamespacestd;typedeflonglongll;constintmaxn=20;constintmaxnn=(1>n>>m>>k;for(in
Nero Alix
·
2020-09-14 20:46
DP
*【
CodeForces
- 1150D】Three Religions(dp,预处理,思维)
题干:DuringthearchaeologicalresearchintheMiddleEastyoufoundthetracesofthreeancientreligions:Firstreligion,SecondreligionandThirdreligion.Youcompiledtheinformationontheevolutionofeachofthesebeliefs,andyo
韬光养晦_
·
2020-09-14 20:45
Codeforce~
动态规划(dp)
Codeforces
Round #450 (Div. 2) ( D. Unusual Sequences 莫比乌斯反演)
题目链接好久没遇到莫比乌斯反演的题了,今天打cf遇到了居然没写出来。特地来补补D.UnusualSequences题意:做法参考来自:博客1、首先隔板法那里解析:将y为y个1然后就是简单的隔板法。最后然后有个地方一直没懂为什么是相等的:现在来分析分析,g(i)里面有很多gcd不同的假设i为6那么g(i)中gcd有四种:1,2,3,6当为2、3、6时,将所有的数除上2、3、6不就变成了,gcd为1了
ccsu_deer
·
2020-09-14 20:45
数论---莫比乌斯反演
【
CodeForces
- 1047B 】Cover Points (数学,构造,思维)
题干:Therearennpointsontheplane,(x1,y1),(x2,y2),…,(xn,yn)(x1,y1),(x2,y2),…,(xn,yn).Youneedtoplaceanisoscelestrianglewithtwosidesonthecoordinateaxistocoverallpoints(apointiscoveredifitliesinsidethetriang
韬光养晦_
·
2020-09-14 20:45
思维
数论
Codeforce~
Educational
Codeforces
Round 66 (Rated for Div. 2) 题解
http://
codeforces
.com/contest/1175/problem/Btimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputYouaregivenafunctionffwritteninsomebasiclanguage
ccsu_deer
·
2020-09-14 20:45
codeforce题解
上一页
54
55
56
57
58
59
60
61
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他