DescriptionHarryandSallywereplayinggamesatChristmasEve.TheydrewsomeChristmastreesonapaper:Thentheytookturnstocutabranchofatree,andremovedthepartofthetreewhichhadalreadynotconnectedwiththeroot.Astepshowsasfollows:Sallyalwaysmovedfirst.Whoremovedthelastpartofthetreeswouldwinthegame.Afterawhile,theyallfiguredoutthebeststrategyandthoughtthegamewastoosimpleforthem.Harrysaid,“TheChristma...
DescriptionLittleJohnisplayingveryfunnygamewithhisyoungerbrother.ThereisonebigboxfilledwithM&Msofdifferentcolors.AtfirstJohnhastoeatseveralM&Msofthesamecolor.Thenhisopponenthastomakeaturn.Andsoon.PleasenotethateachplayerhastoeatatleastoneM&Mduringhisturn.IfJohn(orhisbrother)willeatthelastM&Mfromtheboxhewillbeconsideredasalooserandhewillhavetobuyanewcandybox.Both...
DescriptionLet'splayatraditionalgameNim.YouandIareseatedacrossatableandwehaveahundredstonesonthetable(weknowthenumberofstonesexactly).Weplayinturnandateachturn,youorIcanremoveontofourstonesfromtheheap.Youplayfirstandtheonewhoremovedthelaststoneloses.Inthisgame,youhaveawinningstrategy.Toseethis,youfirstremovefourstonesandleave96stones.NomatterhowIplay,Iwillendupwithleaving92-95stones.T...
DescriptionArthurandhissisterCarollhavebeenplayingagamecalledNimforsometimenow.Nimisplayedasfollows:Thestartingpositionhasanumberofheaps,allcontainingsome,notnecessarilyequal,numberofbeads.Theplayerstaketurnschosingaheapandremovingapositivenumberofbeadsfromit.Thefirstplayernotabletomakeamove,loses.ArthurandCarollreallyenjoyedplayingthissimplegameuntiltheyrecentlylearnedaneasywaytoalwaysb...
DescriptionAliceandBobdecidetoplayafunnygame.Atthebeginningofthegametheypickn(1<=n<=106)coinsinacircle,asFigure1shows.Amoveconsistsinremovingoneortwoadjacentcoins,leavingallothercoinsuntouched.Atleastonecoinmustberemoved.PlayersalternatemoveswithAlicestarting.Theplayerthatremovesthelastcoinwins.(Thelastplayertomovewins.Ifyoucan'tmove,youlose.)Figure1Note:Forn>3,weusec1,c2,....
DescriptionStanandOllieplaythegameofmultiplicationbymultiplyinganintegerpbyoneofthenumbers2to9.Stanalwaysstartswithp=1,doeshismultiplication,thenOlliemultipliesthenumber,thenStanandsoon.Beforeagamestarts,theydrawaninteger1<n<4294967295andthewinneriswhofirstreachesp>=n.InputEachlineofinputcontainsoneintegernumbern.OutputForeachlineofinputoutputonelineeitherStanwins.orOlliewins...
DescriptionLet'sdesignanewchessgame.ThereareNpositionstoholdMchessesinthisgame.Multiplechessescanbelocatedinthesameposition.Thepositionsareconstitutedasatopologicalgraph,i.e.therearedirectededgesconnectingsomepositions,andnocycleexists.TwoplayersyouandImovechessesalternately.Ineachturntheplayershouldmoveonlyonechessfromthecurrentpositiontooneofitsout-positionsalonganedge.Thegamedoesnote...
DescriptionNimisa2-playergamefeaturingseveralpilesofstones.Playersalternateturns,andonhis/herturn,aplayer’smoveconsistsofremoving oneormorestones fromanysinglepile.Playendswhenallthestoneshavebeenremoved,atwhichpointthelastplayertohavemovedisdeclaredthewinner.GivenapositioninNim,yourtaskistodeterminehowmanywinningmovesthereareinthatposition.ApositioninNimiscalled“losing”ifthefirstplay...
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...
近期评论