• <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 閱讀(1094) 評論(1)  編輯 收藏 引用

            評論

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

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

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


            久久99精品九九九久久婷婷| 久久久久亚洲精品中文字幕| 日韩精品久久久久久久电影| 国产成人精品久久亚洲| 久久黄视频| 久久精品亚洲日本波多野结衣| 久久精品人人做人人爽97| 久久精品水蜜桃av综合天堂| 99精品久久久久久久婷婷| 大香伊人久久精品一区二区| 久久久久四虎国产精品| 国内精品久久久久影院薰衣草 | 久久精品国产91久久麻豆自制 | 久久午夜羞羞影院免费观看| 国产精品嫩草影院久久| 97香蕉久久夜色精品国产| 国产欧美久久久精品| 久久人人爽人人爽人人爽| 国产真实乱对白精彩久久| 亚洲精品无码专区久久久| 亚洲午夜无码AV毛片久久| 久久综合九色综合97_久久久| 久久综合偷偷噜噜噜色| 久久国产香蕉一区精品| 国产精品青草久久久久婷婷| 2021久久精品国产99国产精品| 久久一区二区三区99| 99久久www免费人成精品| 久久精品水蜜桃av综合天堂| 国产A级毛片久久久精品毛片| 色欲综合久久躁天天躁| 久久一本综合| 久久久久亚洲AV无码专区网站| 青青草原1769久久免费播放| 国产成人无码精品久久久性色| 偷偷做久久久久网站| 国产精品久久久久a影院| 久久最新免费视频| 久久久久国产日韩精品网站| 国产精品伦理久久久久久| 亚洲国产精品久久久久婷婷老年 |