HaveyoueverplayedHanabi?Ifnot,thenyou'vegottotryitout!Thisproblemdealswithasimplifiedversionofthegame.Overall,thegamehas25typesofcards(5distinctcolorsand5distinctvalues).Boryaisholding n cards.ThegameissomewhatcomplicatedbythefactthateverybodyseesBorya'scardsexceptforBoryahimself.Boryaknowswhichcardshehasbutheknowsnothingabouttheordertheyliein.NotethatBoryacanhavemultipleidenticalcar...
Valeraisacollector.Oncehewantedtoexpandhiscollectionwithexactlyoneantiqueitem.Valeraknows n sellersofantiques,the i-thofthemauctioned ki items.Currentlytheauctionpriceofthe j-thobjectofthe i-thsellerissij.Valeragetsonwellwitheachofthe n sellers.Heisperfectlysurethatifheoutbidsthecurrentpriceofoneoftheitemsintheauction(inotherwords,offersthesellerthemoneythatisstrictlygreaterthanthec...
Devuisarenownedclassicalsinger.Heisinvitedtomanybigfunctions/festivals.Recentlyhewasinvitedto"AllWorldClassicalSingingFestival".OtherthanDevu,comedianChuruwasalsoinvited.Devuhasprovidedorganizersalistofthesongsandrequiredtimeforsingingthem.Hewillsing n songs,ith songwilltake ti minutesexactly.TheComedian,Churuwillcrackjokes.Allhisjokesareof5minutesexactly.Peoplehavemainlycom...
Devubeingasmallkid,likestoplayalot,butheonlylikestoplaywitharrays.Whileplayinghecameupwithaninterestingquestionwhichhecouldnotsolve,canyoupleasesolveitforhim?Givenanarrayconsistingofdistinctintegers.Isitpossibletopartitionthewholearrayinto k disjointnon-emptypartssuchthat p ofthepartshaveevensum(eachofthemmusthaveevensum)andremaining k - p haveoddsum?(notethatpartsneednottobecontinuous...
Petyahas k matches,placedin n matchboxeslyinginalinefromlefttoright.Weknowthat k isdivisibleby n.Petyawantsallboxestohavethesamenumberofmatchesinside.Forthat,hecanmoveamatchfromitsboxtotheadjacentoneinonemove.Howmanysuchmovesdoesheneedtoachievethedesiredconfiguration?InputThefirstlinecontainsinteger n (1 ≤ n ≤ 50000).Thesecondlinecontains n non-negativenumbersthatdonotexce...
PolycarpusadoresTVseries.Rightnowheisreadytofinishwatchingaseasonofapopularsitcom"GraphTheory".Intotal,theseasonhas n episodes,numberedwithintegersfrom 1 to n.Polycarpuswatchesepisodesnotonebyonebutinarandomorder.Hehasalreadywatchedalltheepisodesexceptforone.WhichepisodehasPolycaprusforgottentowatch?InputThefirstlineoftheinputcontainsinteger n (2 ≤ n ≤ 100000) —thenumbe...
Atthechildren'sday,thechildcametoPicks'shouse,andmessedhishouseup.Pickswasangryathim.Alotofimportantthingswerelost,inparticularthefavoritesetofPicks.Fortunately,Picksrememberssomethingabouthisset S:itselementsweredistinctintegersfrom 1 to limit;thevalueof wasequalto sum;here lowbit(x) equals 2k where k isthepositionofthefirstoneinthebinaryrepresentationof x.Forexample, low...
近期评论