DescriptionElinaisreadingabookwrittenbyRujiaLiu,whichintroducesastrangewaytoexpressnon-negativeintegers.Thewayisdescribedasfollowing:Choose k differentpositiveintegers a1, a2, …, ak.Forsomenon-negative m,divideitbyevery ai (1≤ i ≤ k)tofindtheremainder ri.If a1, a2,…, ak areproperlychosen,mcanbedetermined,thenthepairs(ai, ri)canbeusedtoexpress m.“Itiseasytocalculate...
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...
近期评论