VinhworksforanATMmachinemanufacturingcompany.ThebasicfunctionalityofanATMmachineiscashwithdrawal.WhenauserrequestsacashwithdrawalofWVND(VietnameseDong),theATMhastodispenseNmoneynotessuchthattheysumuptoW.ForthenextgenerationofATMmachine,VinhisworkingonanalgorithmtominimizethenumberNofmoneynotesforeachcashwithdrawaltransaction.YourtaskistohelpVinhtodohisjobgiventhatthemon...
Useraintadecidedtopaintawall.Thewallconsistsofn2tiles,thatarearrangedinann × ntable.Sometilesarepainted,andtheothersarenot.Ashewantstopaintitbeautifully,hewillfollowtherulesbelow.Firstlyuseraintalooksatthewall.Ifthereisatleastonepaintedcelloneachrowandatleastonepaintedcelloneachcolumn,hestopscoloring.Otherwise,hegoestostep2.Useraintachooseanytileonthewallwithuniformprobability.Ifthetil...
OnanITlessonValerastudieddatacompression.Theteachertoldaboutanewmethod,whichweshallnowdescribetoyou.Let{a1, a2, ..., an}bethegivensequenceoflinesneededtobecompressed.Hereandbelowweshallassumethatalllinesareofthesamelengthandconsistonlyofthedigits0and1.Let'sdefinethecompressionfunction:f(emptysequence) = emptystringf(s) = s.f(s1, s2) = thesmallestinlengthstring,whichhasoneofthepre...
TheShusekiIslandsareanarchipelagoof30001smallislandsintheYutampoSea.Theislandsareevenlyspacedalongaline,numberedfrom0to30000fromthewesttotheeast.Theseislandsareknowntocontainmanytreasures.TherearengemsintheShusekiIslandsintotal,andthei-thgemislocatedonislandpi.Mr.Kitayutahasjustarrivedatisland0.Withhisgreatjumpingability,hewillrepeatedlyperformjumpsbetweenislandstotheeastaccordingtoth...
近期评论