Minhhasaboxofpencils.TheboxisarectangleofsizeM * N,whereposition(i, j)hasapencilwithalengthofexactlyi * N + j(0 ≤ i ≤ M - 1, 0 ≤ j ≤ N - 1).Notethatposition(0, 0)doesnothaveanypencilhencehavingalengthof0.Hewondersifhecouldselectasub-rectangleoftheboxandjoinallthepencilswithinthatsub-rectangletogether,togetanewlongpencilthathasaspecificlengthLthathewants.Yourta...
WhenSashawasstudyingintheseventhgrade,hestartedlisteningtomusicalot.Inordertoevaluatewhichsongshelikesmore,heintroducedthenotionofthesong'sprettiness.ThetitleofthesongisawordconsistingofuppercaseLatinletters.Theprettinessofthesongistheprettinessofitstitle.Let'sdefinethesimpleprettinessofawordastheratioofthenumberofvowelsinthewordtothenumberofalllettersintheword.Let'sdefinetheprettinessofaw...
Vasyaisstudyinginthelastclassofschoolandsoonhewilltakeexams.Hedecidedtostudypolynomials.PolynomialisafunctionP(x) = a0 + a1x1 + ... + anxn.Numbersaiarecalledcoefficientsofapolynomial,non-negativeintegerniscalledadegreeofapolynomial.Vasyahasmadeabetwithhisfriendsthathecansolveanyproblemwithpolynomials.Theysuggestedhimtheproblem:"DeterminehowmanypolynomialsP(x)existwithintegernon-ne...
Vanyadecidedtowalkinthefieldofsizen × ncells.Thefieldcontainsmappletrees,thei-thappletreeisatthecellwithcoordinates(xi, yi).Vanyamovestowardsvector(dx, dy).ThatmeansthatifVanyaisnowatthecell(x, y),theninasecondhewillbeatcell.Thefollowingconditionissatisfiedforthevector:,whereisthelargestintegerthatdividesbothaandb.Vanyaendshispathwhenhereachesthesquarehehasalreadyvisited.Vanyawonders...
近期评论