Dreamoonlovessummingupsomethingfornoreason.Onedayheobtainstwointegersaandboccasionally.Hewantstocalculatethesumofallniceintegers.Positiveintegerxiscalledniceifand,wherekissomeintegernumberinrange[1, a].Bywedenotethequotientofintegerdivisionofxandy.Bywedenotetheremainderofintegerdivisionofxandy.Youcanreadmoreabouttheseoperationshere:http://goo.gl/AcsXhT.Theanswermaybelarge,sopleaseprint...
DescriptionFJ'sNcows(2<=N<=100,000)arestandingatvariouspositionsalongalongone-dimensionalfence.Theithcowisstandingatpositionx_i(anintegerintherange0...1,000,000,000)andiseitheraplainwhitecoworaspottedcow.Notwocowsoccupythesameposition,andthereisatleastonewhitecow.FJwantstotakeaphotoofacontiguousintervalofcowsforthecountyfair,butinfairnesstohisdifferentcows,hewantstoensurethereareequ...
PolarbearsMenshykovandUsladafromthezooofSt.PetersburgandelephantHoracefromthezooofKievdecidedtobuildahouseofcards.Forthatthey'vealreadyfoundaheftydeckofnplayingcards.Let'sdescribethehousetheywanttomake:Thehouseconsistsofsomenon-zeronumberoffloors.Eachfloorconsistsofanon-zeronumberofroomsandtheceiling.Aroomistwocardsthatareleanedtowardseachother.Theroomsaremadeinarow,eachtwoadjoiningro...
DescriptionFarmerJohnandBessieareplayinggamesagain.Thisonehastodowithtroughsofwater.FarmerJohnhashiddenN(1<=N<=20)troughsbehindthebarn,andhasfilledsomeofthemwithfood.BessiehasaskedM(1<=M<=100)questionsoftheform,"Howmanytroughsfromthislist(whichsherecites)arefilled?".Bessieneedsyourhelptodeducewhichtroughsareactuallyfilled.ConsideranexamplewithfourtroughswhereBessiehasas...
AfteryouhadhelpedGeorgeandAlextomoveinthedorm,theywenttohelptheirfriendFedorplayanewcomputergame«CallofSoldiers3».Thegamehas(m + 1)playersandntypesofsoldiersintotal.Players«CallofSoldiers3»arenumberedform1to(m + 1).Typesofsoldiersarenumberedfrom0ton - 1.Eachplayerhasanarmy.Armyofthei-thplayercanbedescribedbynon-negativeintegerxi.Considerbinaryrepresentationofxi:ifthej-thbit...
近期评论