• <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;
            }
            国产成人久久激情91| 久久久久久久久66精品片| 午夜精品久久久久久99热| 久久精品青青草原伊人| 久久久久亚洲AV无码专区首JN| 久久久精品午夜免费不卡| 久久中文骚妇内射| 精品久久香蕉国产线看观看亚洲| 久久久久无码精品国产| 日韩久久久久久中文人妻| 久久免费高清视频| 久久亚洲sm情趣捆绑调教| 久久精品免费观看| 国产成人久久精品一区二区三区| 国内精品久久久人妻中文字幕| 国产精品久久久久乳精品爆| 99久久99久久精品国产| 亚洲欧美久久久久9999| 亚洲国产成人久久精品动漫| 无码AV波多野结衣久久| 久久久久99精品成人片| avtt天堂网久久精品| 蜜桃麻豆www久久国产精品| 久久99精品综合国产首页| 人妻无码久久一区二区三区免费 | 亚洲国产天堂久久久久久 | 亚洲国产二区三区久久| 久久99久久99精品免视看动漫| 激情五月综合综合久久69| 久久精品一区二区国产| 久久超乳爆乳中文字幕| 亚洲精品乱码久久久久久蜜桃图片| 久久久久久久久久久免费精品| 久久精品嫩草影院| 亚洲综合久久综合激情久久| 国产99精品久久| 伊人久久综合热线大杳蕉下载| 国产午夜福利精品久久2021| 久久久久人妻一区精品性色av| 久久精品国产亚洲αv忘忧草 | 久久一区二区三区免费|