• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            最大公約數函數gcd(int a,int b)的構造和ax=b (mod n) 的解

            Problem

            Give you a modular equation ax=b (mod n). Count how many different x (0<=x<n) satisfying the equation.

            Input

            The input may contain several test cases.

            Each test contains a line with three integers a, b and n, each integer is positive and no more than 10^9.

            Input is terminated by EOF.

            Output

            For each test case, output a line containing the number of solutions.

            Sample input

            4 2 6

            Sample output

            2

            #include <stdio.h>
            long a,b,n;
            int gcd(long a,long b){
                
            if(a==0){
                    
            return b;
                }

                
            else
                
            {
                    
            return gcd(b%a,a);
                }

            }

            int main(){
                
            while(scanf("%d %d %d",&a,&b,&n)!=EOF){
                    
            long d=gcd(a,n);
                    
            if(b%d==0)
                        printf(
            "%d\n",d);
                    
            else printf("0\n",d);
                }

                
            return 0;
            }
            posted on 2008-04-08 12:53 zhongguoa 閱讀(1104) 評論(1)  編輯 收藏 引用

            評論

            # re: 最大公約數函數gcd(int a,int b)的構造和ax=b (mod n) 的解[未登錄] 2015-06-25 19:25 xxx  回復  更多評論   

            #include <stdio.h>
            long a,b,n;
            int gcd(long a,long b){
            if(a==0){
            return b;
            }
            else
            {
            return gcd(b%a,a);
            }
            }
            int main(){
            while(scanf("%d %d %d",&a,&b,&n)!=EOF){
            long d=gcd(a,n);
            if(b%d==0)
            printf("%d\n",d);
            else printf("0\n",d);
            }
            return 0;
            }
            亚洲国产精品久久久久| 久久久久免费视频| 精品久久久久久久| 久久噜噜久久久精品66| 一本色道久久综合狠狠躁| 久久这里只精品国产99热| 伊人久久大香线蕉成人| 精品久久一区二区| 久久精品国产2020| 久久久久亚洲精品男人的天堂| 国内精品久久久久久久久电影网| 亚洲精品高清久久| 久久精品无码专区免费东京热| 人人狠狠综合88综合久久| 国产精品久久久久久久久| 亚洲狠狠婷婷综合久久蜜芽| 久久久久亚洲AV无码专区网站| 韩国无遮挡三级久久| 亚洲国产精品无码久久SM| 日韩影院久久| 久久久久亚洲AV成人网人人网站| 国产成人综合久久综合| 色婷婷综合久久久久中文| 香蕉久久久久久狠狠色| 久久影视国产亚洲| 久久se精品一区二区影院| 国产福利电影一区二区三区,免费久久久久久久精 | 国产69精品久久久久9999| 久久精品国产亚洲AV高清热| 亚洲精品蜜桃久久久久久| 久久这里的只有是精品23| 亚洲精品国精品久久99热| 亚洲国产精品综合久久网络 | 麻豆成人久久精品二区三区免费| 一级做a爰片久久毛片看看| 亚洲乱码日产精品a级毛片久久 | 日韩va亚洲va欧美va久久| 亚洲精品美女久久久久99小说| 久久大香萑太香蕉av| 久久综合久久美利坚合众国 | 久久国产免费直播|