DescriptionThecowsarebuildingarollercoaster!Theywantyourhelptodesignasfunarollercoasteraspossible,whilekeepingtothebudget.TherollercoasterwillbebuiltonalonglinearstretchoflandoflengthL(1<=L<=1,000).TherollercoastercomprisesacollectionofsomeoftheN(1<=N<=10,000)differentinterchangablecomponents.EachcomponentihasafixedlengthWi(1<=Wi<=L).Duetovaryingterrain,eachcomponen...
Devuwantstodecoratehisgardenwithflowers.Hehaspurchased n boxes,wherethe i-thboxcontains fi flowers.Allflowersinasingleboxareofthesamecolor(hencetheyareindistinguishable).Also,notwoboxeshaveflowersofthesamecolor.NowDevuwantstoselect exactly s flowersfromtheboxestodecoratehisgarden.Devuwouldliketoknow,inhowmanydifferentwayscanheselecttheflowersfromeachbox?Sincethisnumbermaybeverylarg...
Wecallastring good,ifaftermergingalltheconsecutiveequalcharacters,theresultingstringispalindrome.Forexample,"aabba"isgood,becauseafterthemergingstepitwillbecome"aba".Givenastring,youhavetofindtwovalues:thenumberofgoodsubstringsofevenlength;thenumberofgoodsubstringsofoddlength.InputThefirstlineoftheinputcontainsasinglestringoflength n (1 ≤ n ≤ 105).Eachcharacterofthestringwillbeeithe...
Thereare n gamesinafootballtournament.Threeteamsareparticipatinginit.Currently k gameshadalreadybeenplayed.Youareanavidfootballfan,butrecentlyyoumissedthewhole k games.Fortunately,yourememberaguessofyourfriendforthese kgames.Yourfrienddidnottellexactnumberofwinsofeachteam,insteadhethoughtthatabsolutedifferencebetweennumberofwinsoffirstandsecondteamwillbe d1 andthatofbetweensecondand...
Beingaprogrammer,youlikearraysalot.Foryourbirthday,yourfriendshavegivenyouanarray a consistingof n distinct integers.Unfortunately,thesizeof a istoosmall.Youwantabiggerarray!Yourfriendsagreetogiveyouabiggerarray,butonlyifyouareabletoanswerthefollowingquestioncorrectly:isitpossibletosortthearray a (inincreasingorder)byreversing exactlyone segmentof a?Seedefinitionsofsegmentandreve...
AfterwinninggoldandsilverinIOI2014,AkshatandMalvikawanttohavesomefun.Nowtheyareplayingagameonagridmadeof nhorizontaland m verticalsticks.An intersectionpoint isanypointonthegridwhichisformedbytheintersectionofonehorizontalstickandoneverticalstick.Inthegridshownbelow, n = 3 and m = 3.Thereare n + m = 6 sticksintotal(horizontalsticksareshowninredandverticalsticksareshowni...
DescriptionFJandhiscowsenjoyplayingamentalgame.Theywritedownthenumbersfrom1toN(1<=N<=10)inacertainorderandthensumadjacentnumberstoproduceanewlistwithonefewernumber.Theyrepeatthisuntilonlyasinglenumberisleft.Forexample,oneinstanceofthegame(whenN=4)mightgolikethis:31244367916BehindFJ'sback,thecowshavestartedplayingamoredifficultgame,inwhichtheytrytodeterminethestartingsequencefromo...
近期评论