• <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 閱讀(1096) 評論(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;
            }
            久久成人影院精品777| 久久久无码精品亚洲日韩按摩| 国产成人精品久久免费动漫| 国产成人久久精品区一区二区| 亚洲国产精品久久久久婷婷软件| 91精品久久久久久无码| 武侠古典久久婷婷狼人伊人| 久久一区二区三区免费| 久久国产精品无码HDAV| 久久久久亚洲AV无码专区桃色| 7777久久久国产精品消防器材| 狠狠干狠狠久久| 久久久久久久综合狠狠综合| 久久成人精品视频| 狠狠色噜噜色狠狠狠综合久久| 99久久精品国产毛片| 久久人人爽人人爽人人片AV麻烦 | 青青青青久久精品国产h久久精品五福影院1421 | 久久精品中文字幕有码| 一本色道久久99一综合| 国产精品丝袜久久久久久不卡| 久久丫精品国产亚洲av| 久久国产欧美日韩精品免费| 一级做a爰片久久毛片16| 久久久久AV综合网成人 | 国产成年无码久久久久毛片| 亚洲精品97久久中文字幕无码| 国产精品久久久久久久午夜片| 狠狠色婷婷久久一区二区三区| 久久精品中文无码资源站| 精品久久久久中文字幕一区| 国产成人久久激情91| 久久精品国产99国产精偷| 熟妇人妻久久中文字幕| 亚洲乱码中文字幕久久孕妇黑人 | 久久婷婷综合中文字幕| 狠狠88综合久久久久综合网| 久久99这里只有精品国产| 中文字幕久久精品| 久久综合久久综合亚洲| 久久久国产精华液|