• <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久久精品国产一区二区| 久久久久久久亚洲Av无码| 久久综合久久综合久久综合| 麻豆精品久久久一区二区| 亚洲欧美日韩精品久久| 国产精品亚洲综合久久| 久久婷婷成人综合色综合| 无码AV中文字幕久久专区| 国产精品女同久久久久电影院| 99久久精品免费观看国产| 精品国产乱码久久久久软件| 久久亚洲春色中文字幕久久久| 久久九九有精品国产23百花影院| 久久免费大片| 久久96国产精品久久久| 狠狠综合久久AV一区二区三区| 久久精品一区二区国产| 久久夜色精品国产噜噜亚洲a| 97久久精品无码一区二区天美| 久久嫩草影院免费看夜色| 久久99亚洲网美利坚合众国| 久久夜色精品国产亚洲| 精品无码久久久久久久久久| 久久久精品人妻一区二区三区蜜桃| 亚洲国产成人久久一区WWW| 亚洲国产天堂久久综合网站| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 久久国产精品免费一区二区三区 | 国产激情久久久久影院小草| 香蕉久久夜色精品升级完成| 四虎影视久久久免费观看| 99久久国产综合精品五月天喷水 | 久久婷婷午色综合夜啪| 久久国产成人| 免费一级欧美大片久久网 | 伊人久久大香线蕉精品不卡| 国产综合精品久久亚洲| 国产视频久久| 久久影院亚洲一区| 亚洲精品99久久久久中文字幕| 久久伊人色|