DescriptionTherepetitionnumberofastringisdefinedasthemaximumnumberRsuchthatthestringcanbepartitionedintoRsameconsecutivesubstrings.Forexample,therepetitionnumberof"ababab"is3and"ababa"is1.Givenastringcontaininglowercaseletters,youaretofindasubstringofitwithmaximumrepetitionnumber.InputTheinputconsistsofmultipletestcases.Eachtestcasecontainsexactlyoneline,whichgivesanon-emptystringconsisti...
Givenasequenceofintegersa1, ..., anandqqueriesx1, ..., xqonit.Foreachqueryxiyouhavetocountthenumberofpairs(l, r)suchthat1 ≤ l ≤ r ≤ nandgcd(al, al + 1, ..., ar) = xi.isagreatestcommondivisorofv1, v2, ..., vn,thatisequaltoalargestpositiveintegerthatdividesallvi.InputThefirstlineoftheinputcontainsintegern,(1 ≤ n ≤ 105),denotingthelengthofthesequence.Thenextlinecont...
DescriptionForthedailymilking,FarmerJohn'sNcows(1<=N<=50,000)alwayslineupinthesameorder.OnedayFarmerJohndecidestoorganizeagameofUltimateFrisbeewithsomeofthecows.Tokeepthingssimple,hewilltakeacontiguousrangeofcowsfromthemilkinglineuptoplaythegame.However,forallthecowstohavefuntheyshouldnotdiffertoomuchinheight.FarmerJohnhasmadealistofQ(1<=Q<=200,000)potentialgroupsofcow...
近期评论