跪求高手帮忙解答ACM程序代码
Theinputfilewillcontainoneormorelines,eachlinecontainingoneintegernwith,representingthenumberofcitiesinthecountry.
Inputisterminatedbyavalueofzero(0)forn.
输入34567891011120输出252431123816
Toputanendtothisproblem,theUniversityofUlmhasdevelopedacontingencyschemefortimesofpeakloadtocutoffnetaccessforsomecitiesofthecountryinasystematic,totallyfairmanner.Germany'scitieswereenumeratedrandomlyfrom1ton.Freiburgwasnumber1,Ulmwasnumber2,Karlsruhewasnumber3,andsooninapurelyrandomorder.
Thenanumbermwouldbepickedatrandom,andInternetaccesswouldfirstbecutoffincity1(clearlythefaireststartingpoint)andthenineverymthcityafterthat,wrappingaroundto1aftern,andignoringcitiesalreadycutoff.Forexample,ifn=17andm=5,netaccesswouldbecutofftothecitiesintheorder[1,6,11,16,5,12,2,9,17,10,4,15,14,3,8,13,7].TheproblemisthatitisclearlyfairesttocutoffUlmlast(afterall,thisiswherethebestprogrammerscomefrom),soforagivenn,therandomnumbermneedstobecarefullychosensothatcity2isthelastcityselected.
邮箱:联系方式: