Onceuponatimeachildgotatestconsistingofmultiple-choicequestionsashomework.Amultiple-choicequestionconsistsoffourchoices: A, B, C and D.Eachchoicehasadescription,andthechildshouldfindouttheonlyonethatiscorrect.Fortunatelythechildknowshowtosolvesuchcomplicatedtest.Thechildwillfollowthealgorithm:Ifthereissomechoicewhosedescriptionatleasttwiceshorterthanallotherdescriptions,oratleasttwi...
OnChildren'sDay,thechildgotatoyfromDelayyyasapresent.However,thechildissonaughtythathecan'twaittodestroythetoy.Thetoyconsistsof n partsand m ropes.Eachropelinkstwoparts,buteverypairofpartsislinkedbyatmostonerope.Tosplitthetoy,thechildmustremoveallitsparts.Thechildcanremoveasinglepartatatime,andeachremoveconsumeanenergy.Let'sdefineanenergyvalueofpart i as vi.Thechildspend vf1 + ...
Inthisproblem,yourtaskistouseASCIIgraphicstopaintacardiogram.Acardiogramisapolylinewiththefollowingcorners:Thatis,acardiogramisfullydefinedbyasequenceofpositiveintegers a1, a2, ..., an.Yourtaskistopaintacardiogrambygivensequence ai.InputThefirstlinecontainsinteger n (2 ≤ n ≤ 1000).Thenextlinecontainsthesequenceofintegersa1, a2, ..., an (1 ≤ ai ≤ 1000).Itisguaran...
Pashahasapositiveinteger a withoutleadingzeroes.Todayhedecidedthatthenumberistoosmallandheshouldmakeitlarger.Unfortunately,theonlyoperationPashacandoistoswaptwoadjacentdecimaldigitsoftheinteger.HelpPashacountthemaximumnumberhecangetifhehasthetimetomakeatmost k swaps.InputThesinglelinecontainstwointegers a and k (1 ≤ a ≤ 1018; 0 ≤ k ≤ 100).OutputPrintthemaximumnumbert...
It'sthattimeoftheyearwhentheRussiansfloodtheircountrysidesummercottages(dachas)andthebusstophasalotofpeople.Peoplerarelygotothedachaontheirown,it'susuallyagroup,sothepeoplestandinqueuebygroups.Thebusstopqueuehas n groupsofpeople.The i-thgroupfromthebeginninghas ai people.Every30 minutesanemptybusarrivesatthebusstop,itcancarryatmost m people.Naturally,thepeoplefromthefirstgroupentert...
DescriptionFarmerJohnwenttocutsomewoodandleftN(2<=N<=100,000)cowseatingthegrass,asusual.Whenhereturned,hefoundtohishorrorthatthecowswereinhisgardeneatinghisbeautifulflowers.Wantingtominimizethesubsequentdamage,FJdecidedtotakeimmediateactionandtransportthecowsbacktotheirbarn.EachcowiisatalocationthatisTiminutes(1<=Ti<=2,000,000)awayfromthebarn.Furthermore,whilewaitingfortra...
近期评论