DescriptionBuffaloBillwishestocrossa1000x1000squarefield.Anumberofsnakesareonthefieldatvariouspositions,andeachsnakecanstrikeaparticulardistanceinanydirection.CanBillmakethetripwithoutbeingbitten?InputAssumethatthesouthwestcornerofthefieldisat(0,0)andthenorthwestcornerat(0,1000).Theinputconsistsofalinecontainingn<=1000,thenumberofsnakes.Alinefollowsforeachsnake,containingthreerealnumb...
DescriptionAprefixofastringisasubstringstartingatthebeginningofthegivenstring.Theprefixesof"carbon"are:"c","ca","car","carb","carbo",and"carbon".Notethattheemptystringisnotconsideredaprefixinthisproblem,buteverynon-emptystringisconsideredtobeaprefixofitself.Ineverydaylanguage,wetendtoabbreviatewordsbyprefixes.Forexample,"carbohydrate"iscommonlyabbreviatedby"carb".Inthisproblem,givenasetofwo...
DescriptionThecowsaregoingtospace!Theyplantoachieveorbitbybuildingasortofspaceelevator:agianttowerofblocks.TheyhaveK(1<=K<=400)differenttypesofblockswithwhichtobuildthetower.Eachblockoftypeihasheighth_i(1<=h_i<=100)andisavailableinquantityc_i(1<=c_i<=10).Duetopossibledamagecausedbycosmicrays,nopartofablockoftypeicanexceedamaximumaltitudea_i(1<=a_i<=40000).Helptheco...
DescriptionAfteralonglastingwaronwords,awaronarmsfinallybreaksoutbetweenlittleken’sandKnuthOcean’skingdoms.AsuddenandviolentassaultbyKnuthOcean’sforcehasrenderedatotalfailureoflittleken’scommandnetwork.Aprovisionalnetworkmustbebuiltimmediately.littlekenorderssnoopytotakechargeoftheproject.Withthesituationstudiedtoeverydetail,snoopybelievesthatthemosturgentpointistoenablelittenken’sco...
Youhave a nutsandlotsofboxes.Theboxeshaveawonderfulfeature:ifyouput x (x ≥ 0) divisors(thespacialbarsthatcandivideabox)toit,yougetabox,dividedinto x + 1 sections.Youareminimalist.Therefore,ontheonehand,youareagainstdividingsomeboxintomorethan k sections.Ontheotherhand,youareagainstputtingmorethan v nutsintosomesectionofthebox.Whatistheminimumnumberofboxesyouhavetouseifyouwant...
TheQueenofEnglandhas n treesgrowinginarowinhergarden.Atthat,the i-th (1 ≤ i ≤ n) treefromthelefthasheight aimeters.TodaytheQueendecidedtoupdatethesceneryofhergarden.Shewantsthetrees'heightstomeetthecondition:foralli (1 ≤ i < n), ai + 1 - ai = k,where k isthenumbertheQueenchose.Unfortunately,theroyalgardenerisnotamachineandhecannotfulfillthedesireoftheQueenin...
近期评论