LittleDimamisbehavedduringamathlessonalotandthenastyteacherMr.Picklesgavehimthefollowingproblemasapunishment.Findallintegersolutions x (0 < x < 109) oftheequation:x = b·s(x)a + c, where a, b, c aresomepredeterminedconstantvaluesandfunction s(x) determinesthesumofalldigitsinthedecimalrepresentationofnumber x.TheteachergivesthisproblemtoDimaforeachlesson.Hechangeson...
Vasyahas n pairsofsocks.InthemorningofeachdayVasyahastoputonapairofsocksbeforehegoestoschool.Whenhecomeshomeintheevening,Vasyatakesofftheusedsocksandthrowsthemaway.Every m-thday(atdayswithnumbers m, 2m, 3m, ...)mombuysapairofsockstoVasya.Shedoesitlateintheevening,sothatVasyacannotputonanewpairofsocksbeforethenextday.HowmanyconsecutivedayspassuntilVasyarunsoutofsocks?InputThesin...
RecentlyPashmakhasbeenemployedinatransportationcompany.Thecompanyhas k busesandhasacontractwithaschoolwhichhas n students.Theschoolplannedtotakethestudentsto d differentplacesfor d days(eachdayinoneplace).Eachdaythecompanyprovidesallthebusesforthetrip.Pashmakhastoarrangethestudentsinthebuses.Hewantstoarrangethestudentsinawaythatnotwostudentsbecomeclosefriends.Inhisridiculousidea,tw...
PashmakdecidedtogiveParmidaapairofflowersfromthegarden.Thereare n flowersinthegardenandthe i-thofthemhasabeautynumber bi.Parmidaisaverystrangegirlsoshedoesn'twanttohavethetwomostbeautifulflowersnecessarily.Shewantstohavethosepairsofflowersthattheirbeautydifferenceismaximalpossible!Yourtaskistowriteaprogramwhichcalculatestwothings:ThemaximumbeautydifferenceofflowersthatPashmakcangivetoP...
PashmakhasfalleninlovewithanattractivegirlcalledParmidasinceoneyearago...Today,Pashmaksetupameetingwithhispartnerinaromanticgarden.Unfortunately,Pashmakhasforgottenwherethegardenis.Butheremembersthatthegardenlookslikeasquarewithsidesparalleltothecoordinateaxes.Healsoremembersthatthereisexactlyonetreeoneachvertexofthesquare.Now,Pashmakknowsthepositionofonlytwoofthetrees.Helphimtofindthep...
近期评论