KitaharaHarukihasbought n applesforToumaKazusaandOgisoSetsuna.Nowhewantstodividealltheapplesbetweenthefriends.Eachappleweights100gramsor200grams.OfcourseKitaharaHarukidoesn'twanttooffendanyofhisfriend.ThereforethetotalweightoftheapplesgiventoToumaKazusamustbeequaltothetotalweightoftheapplesgiventoOgisoSetsuna.ButunfortunatelyKitaharaHarukidoesn'thaveakniferightnow,sohecannotsp...
KuriyamaMiraihaskilledmanymonstersandgotmany(namely n)stones.Shenumbersthestonesfrom 1 to n.Thecostofthe i-thstoneis vi.KuriyamaMiraiwantstoknowsomethingaboutthesestonessoshewillaskyoutwokindsofquestions:Shewilltellyoutwonumbers, l and r (1 ≤ l ≤ r ≤ n),andyoushouldtellher .Let ui bethecostofthe i-thcheapeststone(thecostthatwillbeonthe i-thplaceifwearrangealltheston...
DescriptionFarmerJohn'sN(1<=N<=50,000)cows(numbered1..N)areplanningtorunawayandjointhecircus.Theirhoofedfeetpreventthemfromtightropewalkingandswingingfromthetrapeze(andtheirlastattemptatfiringacowoutofacannonmetwithadismalfailure).Thus,theyhavedecidedtopracticeperformingacrobaticstunts.Thecowsaren'tterriblycreativeandhaveonlycomeupwithoneacrobaticstunt:standingontopofeachothertoform...
Manystudentsliveinadormitory.Adormitoryisawholenewworldoffunnyamusementsandpossibilitiesbutitdoeshaveitsdrawbacks.Thereisonlyoneshowerandtherearemultiplestudentswhowishtohaveashowerinthemorning.That'swhyeverymorningthereisalineoffivepeopleinfrontofthedormitoryshowerdoor.Assoonastheshoweropens,thefirstpersonfromthelineenterstheshower.Afterawhilethefirstpersonleavestheshowerandthenextpersonent...
Quiterecently,averysmartstudentnamedJurydecidedthatlecturesareboring,sohedownloadedagamecalled"BlackSquare"onhissupercooltouchscreenphone.Inthisgame,thephone'sscreenisdividedintofourverticalstrips.Eachsecond,ablacksquareappearsonsomeofthestrips.Accordingtotherulesofthegame,Jurymustusethissecondtotouchthecorrespondingstriptomakethesquaregoaway.AsJuryisbothsmartandlazy,hecountedthathewaste...
Youhaveanarray a[1], a[2], ..., a[n],containingdistinctintegersfrom 1 to n.Yourtaskistosortthisarrayinincreasingorderwiththefollowingoperation(youmayneedtoapplyitmultipletimes):choosetwoindexes, i and j (1 ≤ i < j ≤ n; (j - i + 1) isaprimenumber);swaptheelementsonpositions i and j;inotherwords,youareallowedtoapplythefollowingsequenceofassignments: tmp = a[i], a...
DescriptionFarmerJohnmadeaprofitlastyear!Hewouldliketoinvestitwellbutwondershowmuchmoneyhewillmake.HeknowstheinterestrateR(anintegerbetween0and20)thatiscompoundedannuallyathisbank.HehasanintegeramountofmoneyMintherange100..1,000,000.HeknowshowmanyyearsY(range:0..400)heintendstoinvestthemoneyinthebank.Helphimlearnhowmuchmoneyhewillhaveinthefuturebycompoundingtheinterestforeachyearhesaves...
近期评论