• <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免费网站| 精品综合久久久久久97| 99久久免费国产精精品| 嫩草影院久久99| 久久精品国产亚洲Aⅴ蜜臀色欲| 狠狠精品干练久久久无码中文字幕 | 久久精品一区二区三区AV| 亚洲中文字幕无码久久2017| 久久精品国产亚洲欧美| 性做久久久久久久久| 欧美黑人又粗又大久久久| 久久国产V一级毛多内射| 亚洲欧美日韩中文久久| 99久久伊人精品综合观看| 久久99这里只有精品国产| 国产精品久久国产精麻豆99网站| 久久久久18| 久久精品国产一区二区三区日韩| 午夜视频久久久久一区| 欧美一区二区精品久久| 97精品依人久久久大香线蕉97 | 亚洲精品tv久久久久| 久久精品99久久香蕉国产色戒| 久久无码一区二区三区少妇| 99久久国产热无码精品免费| 久久国产劲爆AV内射—百度| 久久久99精品成人片中文字幕 | Xx性欧美肥妇精品久久久久久| 亚洲国产精品无码久久久蜜芽 | 亚洲国产精品综合久久一线| 99久久婷婷免费国产综合精品| 久久久久亚洲AV无码专区首JN | 亚洲а∨天堂久久精品| 亚洲国产成人久久精品影视| 91精品国产9l久久久久| 2021少妇久久久久久久久久| 久久精品亚洲精品国产色婷| 久久精品成人欧美大片| 精品久久久中文字幕人妻| 久久综合九色综合网站| 午夜精品久久久久久久|