• <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 閱讀(1095) 評論(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久久成人18免费网站| 久久99精品久久久久婷婷| 久久精品国产亚洲av麻豆小说| 久久高清一级毛片| 日韩AV毛片精品久久久| 亚洲国产精品久久电影欧美| 97久久国产亚洲精品超碰热| 久久精品无码一区二区三区免费 | 777米奇久久最新地址| 国产亚洲精久久久久久无码| 狠狠久久综合| 新狼窝色AV性久久久久久| 久久九九有精品国产23百花影院| 久久精品一区二区三区中文字幕| 久久亚洲熟女cc98cm| 97久久久精品综合88久久| 少妇人妻综合久久中文字幕| av无码久久久久不卡免费网站| 久久久久国产| 久久亚洲国产中v天仙www| 精品一二三区久久aaa片| 精品国产婷婷久久久| 99久久超碰中文字幕伊人| 99久久免费国产精品特黄| 久久电影网一区| 久久精品aⅴ无码中文字字幕重口 久久精品a亚洲国产v高清不卡 | 国产精品狼人久久久久影院| 久久久久av无码免费网| 国产精品女同一区二区久久| 久久发布国产伦子伦精品| 深夜久久AAAAA级毛片免费看 | 久久久久亚洲av无码专区喷水 | 亚洲国产精品成人久久| 亚洲欧美一区二区三区久久| 久久成人18免费网站| 久久精品中文字幕有码| 99久久精品九九亚洲精品| 国产V综合V亚洲欧美久久| 99久久er这里只有精品18| 热re99久久精品国99热| 中文字幕乱码人妻无码久久|