• <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;
            }
            久久久精品久久久久特色影视| 欧洲性大片xxxxx久久久| 国产综合久久久久| 精品人妻伦一二三区久久| 亚洲人成精品久久久久 | 999久久久无码国产精品| 思思久久99热免费精品6| 国内精品九九久久精品| 久久福利青草精品资源站| 久久久无码一区二区三区| 精品久久亚洲中文无码| 久久精品国产福利国产琪琪| 中文字幕人妻色偷偷久久 | 精品久久亚洲中文无码| 久久综合九色综合久99| 99久久婷婷免费国产综合精品| 国产精品无码久久四虎| 国产精品99久久精品爆乳| 亚洲AV日韩AV天堂久久| 亚洲国产精品嫩草影院久久| 久久婷婷五月综合色99啪ak| 久久久久99精品成人片| www性久久久com| 一本一本久久a久久综合精品蜜桃| 久久精品中文字幕一区| 日本久久久精品中文字幕| 久久综合九色综合久99| 久久精品麻豆日日躁夜夜躁| 久久久久精品国产亚洲AV无码| 精品免费久久久久国产一区| 亚洲天堂久久精品| 成人a毛片久久免费播放| 9久久9久久精品| 99久久综合狠狠综合久久止| 国产V综合V亚洲欧美久久 | 久久精品三级视频| 国产伊人久久| 久久精品国产精品亚洲| 久久一区二区三区99| 午夜精品久久久久久影视777| 久久久久国色AV免费观看|