• <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>

            最大公約數(shù)函數(shù)gcd(int a,int b)的構(gòu)造和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 閱讀(1096) 評(píng)論(1)  編輯 收藏 引用

            評(píng)論

            # re: 最大公約數(shù)函數(shù)gcd(int a,int b)的構(gòu)造和ax=b (mod n) 的解[未登錄](méi) 2015-06-25 19:25 xxx  回復(fù)  更多評(píng)論   

            #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;
            }

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            囯产精品久久久久久久久蜜桃| 亚洲va中文字幕无码久久| 久久婷婷五月综合色奶水99啪| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 久久精品人人做人人妻人人玩| 久久夜色撩人精品国产| 久久99精品国产麻豆蜜芽| 亚洲精品WWW久久久久久| 亚洲国产精品一区二区久久hs | 91视频国产91久久久| 久久婷婷国产麻豆91天堂| 欧美久久久久久午夜精品| 尹人香蕉久久99天天拍| 精品国产一区二区三区久久| 一本大道久久a久久精品综合| 久久久久99精品成人片| 99久久国产综合精品女同图片| 91精品国产高清久久久久久国产嫩草| 狠狠人妻久久久久久综合| 国产精品99久久久久久宅男小说| 国产精品久久久天天影视| 99久久国产综合精品成人影院| 麻豆成人久久精品二区三区免费 | 日本精品久久久久中文字幕| 亚洲国产精品久久久久网站| 久久国产欧美日韩精品| 久久精品无码一区二区三区日韩 | 久久国产福利免费| 一本色道久久88精品综合 | 亚洲国产精品成人AV无码久久综合影院 | 91精品婷婷国产综合久久| 久久亚洲中文字幕精品有坂深雪 | 精品国产乱码久久久久久郑州公司| 久久久久久久久久久免费精品| 国产精品久久久久jk制服| 亚洲AV日韩AV永久无码久久 | 久久久亚洲欧洲日产国码aⅴ| 波多野结衣久久一区二区| 国产免费久久精品99久久| 久久精品国产精品亚洲下载| 麻豆精品久久精品色综合|