• <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;
            }
            无码人妻精品一区二区三区久久 | 久久国产精品免费| 丁香久久婷婷国产午夜视频| 日日狠狠久久偷偷色综合96蜜桃| 伊人色综合久久天天| 亚洲人成无码www久久久| 久久精品人人做人人爽97| 国产精品无码久久久久久| 亚洲欧美精品一区久久中文字幕| 久久综合九色综合97_久久久| 大香网伊人久久综合网2020| 性做久久久久久久久| 9191精品国产免费久久| 中文字幕乱码久久午夜| 国产免费久久精品99久久| 色欲av伊人久久大香线蕉影院| 欧美日韩精品久久久久| 欧美激情精品久久久久| 久久婷婷是五月综合色狠狠| 9191精品国产免费久久| 97r久久精品国产99国产精| 久久精品一本到99热免费| 亚洲国产成人久久综合碰| 伊人久久免费视频| 久久久精品免费国产四虎| 久久国产精品成人免费| 久久久精品2019免费观看 | 日本欧美久久久久免费播放网| 久久久久久久综合综合狠狠| 久久精品国产久精国产思思| 综合久久国产九一剧情麻豆| 人妻少妇久久中文字幕| 久久人妻AV中文字幕| 亚洲精品无码久久一线| 亚洲综合伊人久久大杳蕉| 亚洲国产精品久久久天堂| 99久久99久久久精品齐齐| 一本久久a久久精品综合夜夜| 久久综合九色综合97_久久久| 91精品国产高清91久久久久久| 久久午夜伦鲁片免费无码|