• <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 閱讀(1096) 評論(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;
            }
            国内精品久久久人妻中文字幕| 亚洲AV无码一区东京热久久| 精品久久久久久久| 伊人久久大香线蕉精品| 国产精品久久久天天影视香蕉 | 一级a性色生活片久久无| 伊人久久精品影院| 久久综合亚洲欧美成人| 久久成人18免费网站| 人妻无码αv中文字幕久久琪琪布| 一本久道久久综合狠狠爱| 久久久久久综合一区中文字幕| 久久精品三级视频| www.久久热| 久久中文字幕人妻熟av女| 精品午夜久久福利大片| 欧美亚洲国产精品久久久久| 九九久久99综合一区二区| 欧美午夜A∨大片久久 | 99国产精品久久| 国产精品久久久久久久app | 久久久久国产一级毛片高清板| 日本五月天婷久久网站| 成人精品一区二区久久久| 久久亚洲精品国产精品| 亚洲精品无码久久久| 国产激情久久久久影院老熟女| 欧美黑人又粗又大久久久| 久久久久久久女国产乱让韩| 国产精品99久久久久久宅男| 国产午夜精品理论片久久影视| 亚洲AV乱码久久精品蜜桃| 国产精品亚洲综合久久| 一级a性色生活片久久无| 欧美午夜A∨大片久久 | 伊人久久大香线蕉精品不卡| a级毛片无码兔费真人久久| 久久er热视频在这里精品| 99精品国产在热久久无毒不卡| 久久永久免费人妻精品下载| 色欲久久久天天天综合网精品|