It'stimepolarbearsMenshykovandUsladafromthezooofSt.PetersburgandelephantHoracefromthezooofKievgotdowntobusiness.Intotal,therearentasksforthedayandeachanimalshoulddoeachofthesetasks.Foreachtask,theyhaveevaluateditsdifficulty.Alsoanimalsdecidedtodothetasksinorderoftheirdifficulty.Unfortunately,sometaskscanhavethesamedifficulty,sotheorderinwhichonecanperformthetasksmayvary.Menshykov,Usla...
TwopolarbearsMenshykovandUsladafromtheSt.PetersburgzooandelephantHoracefromtheKievzoogotsixstickstoplaywithandassesstheanimals'creativity.Menshykov,UsladaandHoracedecidedtomakeeitheranelephantorabearfromthosesticks.Theycanmakeananimalfromsticksinthefollowingway:Foursticksrepresenttheanimal'slegs,thesesticksshouldhavethesamelength.Tworemainingsticksrepresenttheanimal'sheadandbody.Theb...
DescriptionBeingafanofallcold-weathersports(especiallythoseinvolvingcows),FarmerJohnwantstorecordasmuchoftheupcomingwinterMoolympicsaspossible.ThetelevisionschedulefortheMoolympicsconsistsofNdifferentprograms(1<=N<=150),eachwithadesignatedstartingtimeandendingtime.FJhasadual-tunerrecorderthatcanrecordtwoprogramssimultaneously.Pleasehelphimdeterminethemaximumnumberofprogramshecanr...
Tokeepprivacyofmessagesandpreventthealiensfromreadingthem,wemayusevariousencryptionalgorithms.Thesealgorithmsencodeamessageintotheso-calledciphertextthatisdifficult(orimpossible)todecodeforanyoneelsethantheintendedrecipient.Transpositionciphersareatypeofencryptionthatdonotchangethelettersofthemessagebutonlychangetheirorder(“shuffle”theletters).Ofcourse,theshufflingmustbereversibletoallowlate...
GeorgehasrecentlyenteredtheBSUCP(BerlandStateUniversityforCoolProgrammers).GeorgehasafriendAlexwhohasalsoenteredtheuniversity.Nowtheyaremovingintoadormitory.GeorgeandAlexwanttoliveinthesameroom.Thedormitoryhasnroomsintotal.Atthemomentthei-throomhaspipeoplelivinginitandtheroomcanaccommodateqipeopleintotal(pi ≤ qi).YourtaskistocounthowmanyroomshasfreeplaceforbothGeorgeandAlex...
Annhasrecentlystartedcommutingbysubway.Weknowthataoneridesubwayticketcostsarubles.Besides,Annfoundoutthatshecanbuyaspecialticketformrides(shecanbuyitseveraltimes).Itcostsbrubles.Anndidthemath;shewillneedtousesubwayntimes.HelpAnn,tellherwhatistheminimumsumofmoneyshewillhavetospendtomakenrides?InputThesinglelinecontainsfourspace-separatedintegersn,m,a,b(1 ≤ n, m, a, b ≤ 1000)—the...
近期评论