
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...
近期评论