DescriptionBeadsofNcolorsareconnectedtogetherintoacircularnecklaceofNbeads(N<=1000000000).Yourjobistocalculatehowmanydifferentkindsofthenecklacecanbeproduced.YoushouldknowthatthenecklacemightnotuseupalltheNcolors,andtherepetitionsthatareproducedbyrotationaroundthecenterofthecircularnecklaceareallneglected.YouonlyneedtooutputtheanswermoduleagivennumberP.InputThefirstlineoftheinputisa...
Description"LetitBead"companyislocatedupstairsat700CanneryRowinMonterey,CA.Asyoucandeducefromthecompanyname,theirbusinessisbeads.TheirPRdepartmentfoundoutthatcustomersareinterestedinbuyingcoloredbracelets.However,over90percentofthetargetaudienceinsiststhatthebraceletsbeunique.(Justimaginewhathappenediftwowomenshowedupatthesamepartywearingidenticalbracelets!)It'sagoodthingthatbracele...
DescriptionChinesepeoplethinkof'8'astheluckydigit.Bobalsolikesdigit'8'.Moreover,BobhashisownluckynumberL.NowhewantstoconstructhisluckiestnumberwhichistheminimumamongallpositiveintegersthatareamultipleofLandconsistofonlydigit'8'.InputTheinputconsistsofmultipletestcases.EachtestcasecontainsexactlyonelinecontainingL(1≤L≤2,000,000,000).Thelasttestcaseisfollowedbyalinecontainingazero.O...
近期评论