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...
Useraintahasastackof n redandblueballs.Hecanapplyacertainoperationwhichchangesthecolorsoftheballsinsidethestack.Whilethetopballinsidethestackisred,poptheballfromthetopofthestack.Thenreplacetheblueballonthetopwitharedball.Andfinallypushsomeblueballstothestackuntilthestackhastotalof n ballsinside.Iftherearenoblueballsinsidethestack,aintacan'tapplythisoperation.Giventheinitialstateofthesta...
Useraintaismakingawebsite.Thistimeheisgoingtomakeanavigationofthepages.Inhissite,thereare n pagesnumberedbyintegersfrom 1 to n.Assumethatsomebodyisonthe p-thpagenow.Thenavigationwilllooklikethis: << p - k p - k + 1 ... p - 1 (p) p + 1 ... p + k - 1 p + k >>Whensomeoneclicksthebutton"<<"heisredirectedtopage 1,andwhensomeoneclicksth...
OuroldfriendAlexeyhasfinallyenteredtheUniversityofCityN—theBerlandcapital.AlexeyexpectedhisfathertogethimaplacetoliveinbuthisfathersaiditwashightimeforAlexeytopracticesomefinancialindependence.So,Alexeyislivinginadorm.Thedormhasexactlyonestraightdryer—a 100 centimeterlongropetohangclotheson.Thedryerhasgotacoordinatesysteminstalled:theleftmostendofthedryerhascoordinate 0,andtheoppo...
近期评论