NewYeariscominginTreeWorld!Inthisworld,asthenameimplies,therearencitiesconnectedbyn - 1roads,andforanytwodistinctcitiestherealwaysexistsapathbetweenthem.Thecitiesarenumberedbyintegersfrom1ton,andtheroadsarenumberedbyintegersfrom1ton - 1.Let'sdefined(u, v)astotallengthofroadsonthepathbetweencityuandcityv.Asanannualevent,peopleinTreeWorldrepairsexactlyoneroadperyear.Asaresult,theleng...
DescriptionWesaythatintegerx,0<x<p,isaprimitiverootmodulooddprimepifandonlyiftheset{(ximodp)|1<=i<=p-1}isequalto{1,...,p-1}.Forexample,theconsecutivepowersof3modulo7are3,2,6,4,5,1,andthus3isaprimitiverootmodulo7.Writeaprogramwhichgivenanyoddprime3<=p<65536outputsthenumberofprimitiverootsmodulop.InputEachlineoftheinputcontainsanoddprimenumbersp.Inputisterminatedbytheend-of-...
ItturnsoutthatyouareagreatfanofrockbandAC/PE.Peterlearnedthatandstartedthefollowinggame:heplaysthefirstsongofthelistofnsongsofthegroup,andyouhavetofindoutthenameofthesong.Afteryoutellthesongname,Peterimmediatelyplaysthefollowingsonginorder,andsoon.Thei-thsongofAC/PEhasitsrecognizabilitypi.Thismeansthatifthesonghasnotyetbeenrecognizedbyyou,youlistentoitforexactlyonemoresecondandwithpr...
近期评论