ProblemDescriptionOnSaintValentine'sDay,AleximaginedtopresentaspecialpendanttohisgirlfriendmadebyKkindofpearls.Thependantisactuallyastringofpearls,anditslengthisdefinedasthenumberofpearlsinit.Asisknowntoall,Alexisveryrich,andhehasNpearlsofeachkind.Pendantcanbetoldapartaccordingtopermutationofitspearls.Nowhewantstoknowhowmanykindofpendantcanhemade,withlengthbetween1andN.Ofcour...
InnaandDimadecidedtosurpriseSereja.Theybroughtareallyhugecandymatrix,it'sbigevenforSereja!Let'snumbertherowsofthegiantmatrixfrom 1 to n fromtoptobottomandthecolumns—from 1 to m,fromlefttoright.We'llrepresentthecellontheintersectionofthe i-throwand j-thcolumnas (i, j).Justasisexpected,somecellsofthegiantcandymatrixcontaincandies.Overallthematrixhas p candies:the k-thcandyisa...
DescriptionA cellularautomaton isacollectionofcellsonagridofspecifiedshapethatevolvesthroughanumberofdiscretetimestepsaccordingtoasetofrulesthatdescribethenewstateofacellbasedonthestatesofneighboringcells.The orderofthecellularautomaton isthenumberofcellsitcontains.Cellsoftheautomatonoforder n arenumberedfrom1to n.The orderofthecell isthenumberofdifferentvaluesitmaycontain.Usually,v...
DescriptionIntheFibonacciintegersequence, F0 =0, F1 =1,and Fn = Fn −1 + Fn −2 for n ≥2.Forexample,thefirsttentermsoftheFibonaccisequenceare:0,1,1,2,3,5,8,13,21,34,…AnalternativeformulafortheFibonaccisequenceis.Givenaninteger n,yourgoalistocomputethelast4digitsof Fn.InputTheinputtestfilewillcontainmultipletestcases.Eachtestcaseconsistsofasinglelinecontainingn(wh...
近期评论