DescriptionBessie,FarmerJohn'sprizecow,hasjustwonfirstplaceinabovinebeautycontest,earningthetitle'MissCowWorld'.Asaresult,BessiewillmakeatourofN(2<=N<=50,000)farmsaroundtheworldinordertospreadgoodwillbetweenfarmersandtheircows.Forsimplicity,theworldwillberepresentedasatwo-dimensionalplane,whereeachfarmislocatedatapairofintegercoordinates(x,y),eachhavingavalueintherange-10,000...1...
Youhavematrixaofsizen × n.Let'snumbertherowsofthematrixfrom1tonfromtoptobottom,let'snumberthecolumnsfrom1tonfromlefttoright.Let'suseaijtorepresenttheelementontheintersectionofthei-throwandthej-thcolumn.Matrixameetsthefollowingtwoconditions:foranynumbersi, j(1 ≤ i, j ≤ n)thefollowinginequalityholds:aij ≥ 0;.Matrixbisstrictlypositive,ifforanynumbersi, j(1 ≤ i, j ≤ n)theine...
DescriptionGivenasetofsticksofvariouslengths,isitpossibletojointhemend-to-endtoformasquare?InputThefirstlineofinputcontainsN,thenumberoftestcases.Eachtestcasebeginswithaninteger4<=M<=20,thenumberofsticks.Mintegersfollow;eachgivesthelengthofastick-anintegerbetween1and10,000.OutputForeachcase,outputalinecontaining"yes"ifisispossibletoformasquare;otherwiseoutput"no".SampleInput[cray...
DescriptionTeacherMaihasakingdom.Amonsterhasinvadedthiskingdom,andTeacherMaiwantstokillit.MonsterinitiallyhashHP.AnditwilldieifHPislessthan1.TeacherMaiandmonstertaketurnstodotheiraction.Inoneround,TeacherMaicanattackthemonstersothattheHPofthemonsterwillbereducedbya.Attheendofthisround,theHPofmonsterwillbeincreasedbyb.Afterkconsecutiveround'sattack,TeacherMaimusttakearestin...
JohnDoeofferedhissisterJaneDoefindthegcdofsomesetofnumbersa.Gcdisapositiveintegerg,suchthatallnumberfromthesetareevenlydivisiblebygandthereisn'tsuchg'(g' > g),thatallnumbersofthesetareevenlydivisiblebyg'.UnfortunatelyJanecouldn'tcopewiththetaskandJohnofferedhertofindtheghdofthesamesubsetofnumbers.Ghdisapositiveintegerg,suchthatatleasthalfofnumbersfromthesetareevenlydivisiblebygandthe...
ShusekiKingdomistheworld'sleadingnationforinnovationandtechnology.Therearencitiesinthekingdom,numberedfrom1ton.ThankstoMr.Kitayuta'sresearch,ithasfinallybecomepossibletoconstructteleportationpipesbetweentwocities.Ateleportationpipewillconnecttwocitiesunidirectionally,thatis,ateleportationpipefromcityxtocityycannotbeusedtotravelfromcityytocityx.Thetransportationwithineachcityisextremelydeve...
近期评论