Yourteamwasexploringanancientcity.Suddenlyyoufoundanoldscrollwith2integernumbersNandK,whichencryptsthesecretcodetoopenatreasurebox.ConsideringatransformationonanintegerXdescribedasfollows:X = X + X mod 100,thesecretcodecanbeobtainedbyapplyingtheabove-describedtransformationKtimessuccessivelytoN.InputTheinputfileconsistsofseveraldatasets.Thefirstlineoftheinputfilecontainsthenumb...
DescriptionFib数列0,1,1,2,3,5,8,13,21。给出一个数字,用FIB数列各项加加减减来得到。例如10=5+519=21-217=13+5-11070=987+89-5-1InputInthefirstlineofthestandardinputasinglepositiveintegerisgiven(1<=P<=10)thatdenotesthenumberofqueries.ThefollowinglinesholdasinglepositiveintegerKeach1<=K<=10^17.OutputForeachqueryyourprogramshouldprintonthestandardoutputtheminimumnumberofFibona...
Prof.Vasechkinwantstorepresentpositiveinteger n asasumofaddends,whereeachaddendsisanintegernumbercontainingonly1s.Forexample,hecanrepresent121as121=111+11+–1.Helphimtofindtheleastnumberofdigits 1 insuchsum.InputThefirstlineoftheinputcontainsinteger n (1 ≤ n < 1015).OutputPrintexpectedminimalnumberofdigits 1.Sampletest(s)input[crayon-673fb344a578a074186764/]output[crayon-67...
DescriptionAtraditionalgameisplayedbetweentwoplayersonapoolofnnumbers(notnecessarilydistinguishingones).Thefirstplayerwillchoosefromthepoolanumberx1lyingin[a,b](0<a<b),whichmeansa<=x1<=b.Nextthesecondplayershouldchooseanumbery1suchthaty1-x1liesin[a,b](Attention!Thisimpliesy1>x1sincea>0).Thenthefirstplayershouldchooseanumberx2suchthatx2-y1liesin[a,b]...Thegameendswhenoneof...
DescriptionLet'splayatraditionalgameNim.YouandIareseatedacrossatableandwehaveahundredstonesonthetable(weknowthenumberofstonesexactly).Weplayinturnandateachturn,youorIcanremoveontofourstonesfromtheheap.Youplayfirstandtheonewhoremovedthelaststoneloses.Inthisgame,youhaveawinningstrategy.Toseethis,youfirstremovefourstonesandleave96stones.NomatterhowIplay,Iwillendupwithleaving92-95stones.T...
近期评论