• <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 閱讀(1093) 評論(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小说| 久久精品免费一区二区| 国产亚洲婷婷香蕉久久精品| 久久一本综合| 久久99国产乱子伦精品免费| 色欲综合久久躁天天躁| 久久久精品午夜免费不卡| 伊人伊成久久人综合网777| 国产亚洲欧美成人久久片 | 午夜人妻久久久久久久久| 日韩一区二区久久久久久 | 国产精品青草久久久久福利99 | 精品国产91久久久久久久a| 囯产精品久久久久久久久蜜桃| 精品999久久久久久中文字幕 | 久久久久亚洲av毛片大| 99国产欧美久久久精品蜜芽 | 99久久99久久| 久久精品中文无码资源站| 久久久中文字幕日本| 国产精品VIDEOSSEX久久发布| 日韩精品久久久久久久电影蜜臀| 综合久久一区二区三区| 久久国产精品一区| 99久久无码一区人妻| 狠狠狠色丁香婷婷综合久久俺| 国产美女亚洲精品久久久综合| 综合久久给合久久狠狠狠97色 | 久久久久久精品免费免费自慰| 国内精品久久久久久久亚洲| 日韩欧美亚洲综合久久影院d3| 色诱久久久久综合网ywww| 久久久久人妻一区精品色| 精品人妻伦九区久久AAA片69| 国产精品成人久久久| 伊人久久精品无码二区麻豆|