QuiterecentlyacreativestudentLeshahadalectureontrees.AfterthelectureLeshawasinspiredandcameupwiththetreeofhisownwhichhecalleda k-tree.A k-treeisaninfiniterootedtreewhere:eachvertexhasexactly k children;eachedgehassomeweight;ifwelookattheedgesthatgoesfromsomevertextoitschildren(exactly k edges),thentheirweightswillequal 1, 2, 3, ..., k.Thepicturebelowshowsapartofa3-tree.  ...
Manystudentsliveinadormitory.Adormitoryisawholenewworldoffunnyamusementsandpossibilitiesbutitdoeshaveitsdrawbacks.Thereisonlyoneshowerandtherearemultiplestudentswhowishtohaveashowerinthemorning.That'swhyeverymorningthereisalineoffivepeopleinfrontofthedormitoryshowerdoor.Assoonastheshoweropens,thefirstpersonfromthelineenterstheshower.Afterawhilethefirstpersonleavestheshowerandthenextpersonent...
Quiterecently,averysmartstudentnamedJurydecidedthatlecturesareboring,sohedownloadedagamecalled"BlackSquare"onhissupercooltouchscreenphone.Inthisgame,thephone'sscreenisdividedintofourverticalstrips.Eachsecond,ablacksquareappearsonsomeofthestrips.Accordingtotherulesofthegame,Jurymustusethissecondtotouchthecorrespondingstriptomakethesquaregoaway.AsJuryisbothsmartandlazy,hecountedthathewaste...
DescriptionDuringavoyageofthestarshipHakodate-maru(seeProblem1406),researchersfoundstrangesynchronizedmovementsofstars.Havingheardtheseobservations,Dr.Extremeproposedatheoryof"superstars".Donottakethistermasadescriptionofactorsorsingers.Itisarevolutionarytheoryinastronomy.Accordingtothistheory,startsweareobservingarenotindependentobjects,butonlysmallportionsoflargerobjectscalledsuperstar...
Youhaveanarray a[1], a[2], ..., a[n],containingdistinctintegersfrom 1 to n.Yourtaskistosortthisarrayinincreasingorderwiththefollowingoperation(youmayneedtoapplyitmultipletimes):choosetwoindexes, i and j (1 ≤ i < j ≤ n; (j - i + 1) isaprimenumber);swaptheelementsonpositions i and j;inotherwords,youareallowedtoapplythefollowingsequenceofassignments: tmp = a[i], a...
DescriptionLukewantstoupgradehishomecomputernetworkfrom10mbsto100mbs.Hisexistingnetworkuses10base2(coaxial)cablesthatallowyoutoconnectanynumberofcomputerstogetherinalineararrangement.LukeisparticularyproudthathesolvedanastyNP-completeprobleminordertominimizethetotalcablelength.Unfortunately,Lukecannotusehisexistingcabling.The100mbssystemuses100baseT(twistedpair)cables.Each100baseTcable...
近期评论