Useraintadecidedtopaintawall.Thewallconsistsofn2tiles,thatarearrangedinann × ntable.Sometilesarepainted,andtheothersarenot.Ashewantstopaintitbeautifully,hewillfollowtherulesbelow.Firstlyuseraintalooksatthewall.Ifthereisatleastonepaintedcelloneachrowandatleastonepaintedcelloneachcolumn,hestopscoloring.Otherwise,hegoestostep2.Useraintachooseanytileonthewallwithuniformprobability.Ifthetil...
OnanITlessonValerastudieddatacompression.Theteachertoldaboutanewmethod,whichweshallnowdescribetoyou.Let{a1, a2, ..., an}bethegivensequenceoflinesneededtobecompressed.Hereandbelowweshallassumethatalllinesareofthesamelengthandconsistonlyofthedigits0and1.Let'sdefinethecompressionfunction:f(emptysequence) = emptystringf(s) = s.f(s1, s2) = thesmallestinlengthstring,whichhasoneofthepre...
WhenSashawasstudyingintheseventhgrade,hestartedlisteningtomusicalot.Inordertoevaluatewhichsongshelikesmore,heintroducedthenotionofthesong'sprettiness.ThetitleofthesongisawordconsistingofuppercaseLatinletters.Theprettinessofthesongistheprettinessofitstitle.Let'sdefinethesimpleprettinessofawordastheratioofthenumberofvowelsinthewordtothenumberofalllettersintheword.Let'sdefinetheprettinessofaw...
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...
Ann × ntableaisdefinedasfollows:Thefirstrowandthefirstcolumncontainones,thatis:ai, 1 = a1, i = 1foralli = 1, 2, ..., n.Eachoftheremainingnumbersinthetableisequaltothesumofthenumberaboveitandthenumbertotheleftofit.Inotherwords,theremainingelementsaredefinedbytheformulaai, j = ai - 1, j + ai, j - 1.Theseconditionsdefineallthevaluesinthetable.Youaregivenanumbern.Younee...
近期评论