Imaginethatyouareinabuildingthathasexactlynfloors.Youcanmovebetweenthefloorsinalift.Let'snumberthefloorsfrombottomtotopwithintegersfrom1ton.Nowyou'reonthefloornumbera.Youareverybored,soyouwanttotakethelift.Floornumberbhasasecretlab,theentryisforbidden.However,youalreadyareinthemoodanddecidetomakekconsecutivetripsinthelift.Letussupposethatatthemomentyouareonthefloornumberx(initially,youwere...
PachinkoisaJapanesegameplayedforamusementandprizes,andissimilartopinball.Thegameisverysimple:youshootsmallmetalballsintothemachineandtheyfalldown,bouncingofftheobstaclesuntiltheyfallintoagate.Thegateintowhichyourballfallsdeterminesthewinnings.Sinceyoucanmoreorlessdeterminethecolumnintowhichtheballisdropped(bysettingitsinitialspeedanddirection),youcaninfluenceyourwinchances.Youaretocalculatey...
Therearerredandggreenblocksforconstructionofthered-greentower.Red-greentowercanbebuiltfollowingnextrules:Red-greentowerisconsistingofsomenumberoflevels;Letthered-greentowerconsistofnlevels,thenthefirstlevelofthistowershouldconsistofnblocks,secondlevel—ofn - 1blocks,thethirdone—ofn - 2blocks,andsoon—thelastlevelofsuchtowershouldconsistoftheoneblock.Inotherwords,eachsuccessivelevelshould...
Dreamoonhasastringsandapatternstringp.Hefirstremovesexactlyxcharactersfromsobtainingstrings'asaresult.Thenhecalculatesthatisdefinedasthemaximalnumberofnon-overlappingsubstringsequaltopthatcanbefoundins'.Hewantstomakethisnumberasbigaspossible.Moreformally,let'sdefineasmaximumvalueofoveralls'thatcanbeobtainedbyremovingexactlyxcharactersfroms.Dreamoonwantstoknowforallxfrom0to|s|where|s|denotest...
近期评论