Tokeepprivacyofmessagesandpreventthealiensfromreadingthem,wemayusevariousencryptionalgorithms.Thesealgorithmsencodeamessageintotheso-calledciphertextthatisdifficult(orimpossible)todecodeforanyoneelsethantheintendedrecipient.Transpositionciphersareatypeofencryptionthatdonotchangethelettersofthemessagebutonlychangetheirorder(“shuffle”theletters).Ofcourse,theshufflingmustbereversibletoallowlate...
heurbanlegendgoesthatifyougototheGooglehomepageandsearchforGoogle,theuniversewillimplode.Wehaveasecrettoshare...Itistrue!Pleasedon'ttryit,ortellanyone.Allright,maybenot.WearejustkiddingThesameisnottrueforauniversefarfaraway.Inthatuniverse,ifyousearchonanysearchengineforthatsearchengine'sname,theuniversedoesimplode!Tocombatthis,peoplecameupwithaninterestingsolution.Allqueriesarepooledt...
DescriptionFarmerJohnandBessieareplayinggamesagain.Thisonehastodowithtroughsofwater.FarmerJohnhashiddenN(1<=N<=20)troughsbehindthebarn,andhasfilledsomeofthemwithfood.BessiehasaskedM(1<=M<=100)questionsoftheform,"Howmanytroughsfromthislist(whichsherecites)arefilled?".Bessieneedsyourhelptodeducewhichtroughsareactuallyfilled.ConsideranexamplewithfourtroughswhereBessiehasas...
AfteryouhadhelpedFedortofindfriendsinthe«CallofSoldiers3»game,hestoppedstudyingcompletely.Today,theEnglishteachertoldhimtoprepareanessay.Fedordidn'twanttopreparetheessay,soheaskedAlexforhelp.AlexcametohelpandwrotetheessayforFedor.ButFedordidn'tliketheessayatall.NowFedorisgoingtochangetheessayusingthesynonymdictionaryoftheEnglishlanguage.Fedordoesnotwanttochangethemeaningoftheessa...
ThenewITone6hasbeenreleasedrecentlyandGeorgegotreallykeentobuyit.Unfortunately,hedidn'thaveenoughmoney,soGeorgewasgoingtoworkasaprogrammer.Nowhefacedthefollowingproblematthework.Givenasequenceofnintegersp1, p2, ..., pn.Youaretochoosekpairsofintegers:[l1, r1], [l2, r2], ..., [lk, rk] (1 ≤ l1 ≤ r1 < l2 ≤ r2 < ... < lk ≤ rk ≤ n; ri - li + 1 = m)...
AfteryouhadhelpedGeorgeandAlextomoveinthedorm,theywenttohelptheirfriendFedorplayanewcomputergame«CallofSoldiers3».Thegamehas(m + 1)playersandntypesofsoldiersintotal.Players«CallofSoldiers3»arenumberedform1to(m + 1).Typesofsoldiersarenumberedfrom0ton - 1.Eachplayerhasanarmy.Armyofthei-thplayercanbedescribedbynon-negativeintegerxi.Considerbinaryrepresentationofxi:ifthej-thbit...
GeorgehasrecentlyenteredtheBSUCP(BerlandStateUniversityforCoolProgrammers).GeorgehasafriendAlexwhohasalsoenteredtheuniversity.Nowtheyaremovingintoadormitory.GeorgeandAlexwanttoliveinthesameroom.Thedormitoryhasnroomsintotal.Atthemomentthei-throomhaspipeoplelivinginitandtheroomcanaccommodateqipeopleintotal(pi ≤ qi).YourtaskistocounthowmanyroomshasfreeplaceforbothGeorgeandAlex...
YouaregivenastringSwhichconsistsof250000lowercaselatinlettersatmost.WedefineF(x)asthemaximalnumberoftimesthatsomestringwithlengthxappearsinS.Forexampleforstring'ababa'F(3)willbe2becausethereisastring'aba'thatoccurstwice.YourtaskistooutputF(i)foreveryisothat1<=i<=|S|.InputStringSconsistsofatmost250000lowercaselatinletters.OutputOutput|S|lines.Onthei-thlineoutputF(i).Example...
DescriptionThelittlecatismajoringinphysicsinthecapitalofByterland.Apieceofsadnewscomestohimthesedays:hismotherisgettingill.Beingworriedaboutspendingsomuchonrailwaytickets(Byterlandissuchabigcountry,andhehastospend16shoursontraintohishometown),hedecidedonlytosendSMSwithhismother.Thelittlecatlivesinanunrichfamily,sohefrequentlycomestothemobileservicecenter,tocheckhowmuchmoneyhehasspentonS...
近期评论