OneofthemostimportantproductsoftheR1companyisapopular@r1.commailservice.TheR1mailboxesreceiveandsendmillionsofemailseveryday.Today,theonlinenewsthunderedwithterribleinformation.TheR1databasecrashedandalmostnodatacouldbesavedexceptforonebigstring.ThedevelopersassumethatthestringcontainsthelettersofsomeusersoftheR1mail.Recoveringlettersisatediousmostlymanualwork.Sobeforeyoustartthisproces...
Developersoftenfacewithregularexpressionpatterns.Apatternisusuallydefinedasastringconsistingofcharactersandmetacharactersthatsetstherulesforyoursearch.Thesepatternsaremostoftenusedtocheckwhetheraparticularstringmeetsthecertainrules.Inthistask,apatternwillbeastringconsistingofsmallEnglishlettersandquestionmarks('?').Thequestionmarkinthepatternisametacharacterthatdenotesanarbitrarysmalllettero...
TheR1companywantstoholdawebsearchchampionship.Therewere n computersgivenforthecompetition,eachofthemisconnectedtotheInternet.Theorganizersbelievethatthedatatransferspeeddirectlyaffectstheresult.ThehigherthespeedoftheInternetis,thefastertheparticipantwillfindthenecessaryinformation.Therefore,beforethecompetitionstarted,eachcomputerhaditsmaximumpossibledatatransferspeedmeasured.Onthe i-t...
TheR1companyhasrecentlyboughtahighrisebuildinginthecentreofMoscowforitsmainoffice.It'stimetodecoratethenewoffice,andthefirstthingtodoistowritethecompany'ssloganabovethemainentrancetothebuilding.Thesloganofthecompanyconsistsof n characters,sothedecoratorshungalargebanner, n meterswideand 1 meterhigh,dividedinto n equalsquares.Thefirstcharacterofthesloganmustbeinthefirstsquare(theleftm...
Oneday,atthe"RussianCodeCup"eventitwasdecidedtoplayfootballasanoutofcompetitionevent.Allparticipantswasdividedinto n teamsandplayedseveralmatches,twoteamscouldnotplayagainsteachothermorethanonce.TheappointedJudgewasthemostexperiencedmember—Pavel.Butsincehewasthewisestofall,hesoongotboredofthegameandfellasleep.Wakingup,hediscoveredthatthetournamentisoverandtheteamswanttoknowtheresultso...
Duringthe"RussianCodeCup"programmingcompetition,thetestingsystemstoresallsentsolutionsforeachparticipant.Weknowthatmanyparticipantsuserandomnumbersintheirprogramsandareoftensentseveralsolutionswiththesamesourcecodetocheck.Eachparticipantisidentifiedbysomeuniquepositiveinteger k,andeachsentsolution A ischaracterizedbytwonumbers: x —thenumberofdifferentsolutionsthataresentbeforethefirst...
DescriptionFarmerJohnhasaproblem:thedirtroadfromhisfarmtotownhassufferedintherecentrainstormsandnowcontains(1<=N<=10,000)mudpools.FarmerJohnhasacollectionofwoodenplanksoflengthLthathecanusetobridgethesemudpools.Hecanoverlapplanksandtheendsdonotneedtobeanchoredontheground.However,hemustcovereachpoolcompletely.Giventhemudpools,helpFJfigureouttheminimumnumberofplanksheneedsinorderto...
It'sholiday.Mashmokhandhisboss,Bimokh,areplayingagameinventedbyMashmokh.InthisgameMashmokhwritessequenceof n distinctintegersontheboard.ThenBimokhmakesseveral(possiblyzero)moves.Onthefirstmoveheremovesthefirstandthesecondintegerfromfromtheboard,onthesecondmoveheremovesthefirstandthesecondintegeroftheremainingsequencefromtheboard,andsoon.Bimokhstopswhentheboardcontainslessthantwonumbers...
Mashmokhworksinafactory.Attheendofeachdayhemustturnoffallofthelights.Thelightsonthefactoryareindexedfrom 1 to n.Thereare n buttonsinMashmokh'sroomindexedfrom 1 to n aswell.IfMashmokhpushesbuttonwithindex i,theneachlightwithindexnotlessthani thatisstillturnedonturnsoff.Mashmokhisnotveryclever.Soinsteadofpushingthefirstbuttonhepushessomeofthebuttonsrandomlyeachnight.Hepushed m ...
近期评论