• <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 閱讀(1097) 評論(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;
            }
            久久精品男人影院| 亚洲国产成人精品女人久久久 | 99久久综合国产精品二区| 国产激情久久久久影院老熟女| 久久se精品一区二区影院| 久久人人爽人人人人爽AV| 久久福利青草精品资源站| 亚洲精品国产第一综合99久久 | 久久精品国产亚洲AV香蕉| 久久99国产亚洲高清观看首页| 手机看片久久高清国产日韩 | 久久久青草青青亚洲国产免观| 中文字幕亚洲综合久久菠萝蜜 | 久久强奷乱码老熟女网站| 国产99久久久久久免费看| 久久久久亚洲AV片无码下载蜜桃 | 久久久久亚洲av成人网人人软件| 久久免费精品一区二区| 中文国产成人精品久久不卡| 久久久黄片| 99久久国产免费福利| 2021久久精品国产99国产精品 | 久久精品国产亚洲Aⅴ香蕉| 九九99精品久久久久久| 久久久女人与动物群交毛片 | 久久国产成人精品麻豆| 2022年国产精品久久久久| 无码人妻久久一区二区三区免费丨| 亚洲国产成人久久精品99| 亚洲国产精品综合久久一线| 久久久久亚洲av成人无码电影| 狠狠人妻久久久久久综合蜜桃| 亚洲一区中文字幕久久| 伊人丁香狠狠色综合久久| 97久久精品人人做人人爽| 国产精品免费久久久久影院| 国产福利电影一区二区三区,免费久久久久久久精 | 免费无码国产欧美久久18| 久久久午夜精品| 久久精品国产亚洲av麻豆小说 | 日本精品久久久久中文字幕8|