• <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;
            }
            久久久久国产一级毛片高清版| 97超级碰碰碰碰久久久久| 四虎国产精品成人免费久久| 精产国品久久一二三产区区别| 久久天堂AV综合合色蜜桃网| 国产999精品久久久久久| 99久久免费国产精品特黄| 久久亚洲国产欧洲精品一| 久久久久99这里有精品10| 国产99久久九九精品无码| 中文字幕久久波多野结衣av| 久久久久亚洲AV成人网| 国产精品99久久免费观看| 97精品伊人久久大香线蕉| 久久久久亚洲精品男人的天堂 | 久久亚洲AV无码西西人体| 久久国产精品一国产精品金尊| 欧美午夜A∨大片久久 | 久久人人爽人人人人爽AV| 国产国产成人久久精品| 久久久久久狠狠丁香| 久久久久99精品成人片欧美 | 久久久久青草线蕉综合超碰| 久久精品中文字幕有码| 2021国产成人精品久久| 国产精品一久久香蕉国产线看| 影音先锋女人AV鲁色资源网久久| 亚洲国产精品一区二区三区久久| 精品久久人人妻人人做精品| 91性高湖久久久久| 国产精品久久久久…| 精品久久久噜噜噜久久久| 久久综合香蕉国产蜜臀AV| 色诱久久久久综合网ywww| 中文字幕乱码人妻无码久久| 精品综合久久久久久98| 亚洲欧美伊人久久综合一区二区 | 亚洲国产精品狼友中文久久久| 精品久久久久久久中文字幕 | 欧美激情一区二区久久久| 精品久久久久久久久免费影院|