• <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 閱讀(1099) 評論(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;
            }
            伊人久久大香线蕉亚洲五月天| 欧美激情精品久久久久| 欧美伊人久久大香线蕉综合69| 精品综合久久久久久88小说| 久久人人爽人人精品视频| 99久久无色码中文字幕人妻| 久久青青草原精品影院| 国产69精品久久久久观看软件| 国产aⅴ激情无码久久| 国产精品伊人久久伊人电影| 久久精品久久久久观看99水蜜桃| 亚洲狠狠综合久久| 亚洲AV无一区二区三区久久| 国产精品久久久久jk制服| 国产精品久久久久久久午夜片| 久久精品免费一区二区| 久久久无码精品午夜| 97久久天天综合色天天综合色hd| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久99热这里只频精品6| 国产成人精品免费久久久久| 久久伊人五月天论坛| 日韩一区二区久久久久久| 久久精品国产免费观看| 久久se精品一区精品二区国产| 久久婷婷五月综合色奶水99啪| 伊人久久成人成综合网222| 精品多毛少妇人妻AV免费久久| 久久SE精品一区二区| 无夜精品久久久久久| 久久精品无码一区二区三区日韩| 久久精品一区二区国产| 久久精品中文闷骚内射| 色婷婷综合久久久久中文| 久久国语露脸国产精品电影| 久久久国产亚洲精品| 久久亚洲AV无码精品色午夜 | 久久久午夜精品福利内容| 亚洲欧美国产日韩综合久久| 久久久久人妻一区精品| 久久精品国产72国产精福利|