Useraintadecidedtopaintawall.Thewallconsistsofn2tiles,thatarearrangedinann × ntable.Sometilesarepainted,andtheothersarenot.Ashewantstopaintitbeautifully,hewillfollowtherulesbelow.Firstlyuseraintalooksatthewall.Ifthereisatleastonepaintedcelloneachrowandatleastonepaintedcelloneachcolumn,hestopscoloring.Otherwise,hegoestostep2.Useraintachooseanytileonthewallwithuniformprobability.Ifthetil...
JohnDoeofferedhissisterJaneDoefindthegcdofsomesetofnumbersa.Gcdisapositiveintegerg,suchthatallnumberfromthesetareevenlydivisiblebygandthereisn'tsuchg'(g' > g),thatallnumbersofthesetareevenlydivisiblebyg'.UnfortunatelyJanecouldn'tcopewiththetaskandJohnofferedhertofindtheghdofthesamesubsetofnumbers.Ghdisapositiveintegerg,suchthatatleasthalfofnumbersfromthesetareevenlydivisiblebygandthe...
DescriptionChinesepeoplethinkof'8'astheluckydigit.Bobalsolikesdigit'8'.Moreover,BobhashisownluckynumberL.NowhewantstoconstructhisluckiestnumberwhichistheminimumamongallpositiveintegersthatareamultipleofLandconsistofonlydigit'8'.InputTheinputconsistsofmultipletestcases.EachtestcasecontainsexactlyonelinecontainingL(1≤L≤2,000,000,000).Thelasttestcaseisfollowedbyalinecontainingazero.O...
Description 求∑∑((nmodi)*(mmodj))其中1<=i<=n,1<=j<=m,i≠j。Input第一行两个数n,m。Output 一个整数表示答案mod19940417的值SampleInput34SampleOutput1样例说明答案为(3mod1)*(4mod2)+(3mod1)*(4mod3)+(3mod1)*(4mod4)+(3mod2)*(4mod1)+(3mod2)*(4mod3)+(3mod2)*(4mod4)+(3mod3)*(4mod1)+(3mod3)*(4mod2)+(3mod3)*(4mod4)=1数据规模和约定对于100%的数据n,m<=10^9。题解 \[\sum_{i=1}^{n}\sum_{j...
DescriptionGivenaprimeP,2<=P<231,anintegerB,2<=B<P,andanintegerN,2<=N<P,computethediscretelogarithmofN,baseB,moduloP.Thatis,findanintegerLsuchthat[crayon-6768404baefe7298780819/]InputReadseverallinesofinput,eachcontainingP,B,Nseparatedbyaspace,Outputforeachlineprintthelogarithmonaseparateline.Ifthereareseveral,printthesmallest;ifthereisnone,print"nosolution"...
近期评论