DescriptionFarmerJohnneedsnewcows!ThereareNcowsforsale(1<=N<=50,000),andFJhastospendnomorethanhisbudgetofMunitsofmoney(1<=M<=10^14).CowicostsP_imoney(1<=P_i<=10^9),butFJhasKcoupons(1<=K<=N),andwhenheusesacoupononcowi,thecowcostsC_iinstead(1<=C_i<=P_i).FJcanonlyuseonecouponpercow,ofcourse.WhatisthemaximumnumberofcowsFJcanafford?PROBLEMN...
DrazilisplayingamathgamewithVarda.Let'sdefineforpositiveintegerxasaproductoffactorialsofitsdigits.Forexample,.First,theychooseadecimalnumberaconsistingofndigitsthatcontainsatleastonedigitlargerthan1.Thisnumbermaypossiblystartwithleadingzeroes.Thentheyshouldfindmaximumpositivenumberxsatisfyingfollowingtwoconditions:1.xdoesn'tcontainneitherdigit0nordigit1.2.=.Helpfriendsfindsuchnumber.Input...
Vasyahadastrictlyincreasingsequenceofpositiveintegersa1,...,an.Vasyausedittobuildanewsequenceb1,...,bn,wherebiisthesumofdigitsofai'sdecimalrepresentation.Thensequenceaigotlostandallthatremainedissequencebi.Vasyawonderswhatthenumbersaicouldbelike.Ofallthepossibleoptionshelikestheonesequencewiththeminimumpossiblelastnumberan.HelpVasyarestoretheinitialsequence.Itisguaranteedthatsuchasequencea...
Therearenpilesofpebblesonthetable,thei-thpilecontainsaipebbles.Yourtaskistopainteachpebbleusingoneofthekgivencolorssothatforeachcolorcandanytwopilesiandjthedifferencebetweenthenumberofpebblesofcolorcinpileiandnumberofpebblesofcolorcinpilejisatmostone.Inotherwords,let'ssaythatbi, cisthenumberofpebblesofcolorcinthei-thpile.Thenforany1 ≤ c ≤ k,1 ≤ i, j ≤ nthefollowingconditionmustbe...
Anyalovestowatchhorrormovies.Inthebesttraditionsofhorror,shewillbevisitedbymghoststonight.Anyahaslotsofcandlespreparedforthevisits,eachcandlecanproducelightforexactlytseconds.Ittakesthegirlonesecondtolightonecandle.Moreformally,Anyacanspendonesecondtolightonecandle,thenthiscandleburnsforexactlytsecondsandthengoesoutandcannolongerbeused.ForeachofthemghostsAnyaknowsthetimeatwhichitcomes:thei...
近期评论