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


            伊人久久久AV老熟妇色| 久久精品免费大片国产大片| 7777精品久久久大香线蕉| 无码人妻久久一区二区三区| 777米奇久久最新地址| 久久综合九色综合欧美狠狠| 久久精品无码一区二区日韩AV| 久久影视综合亚洲| 亚洲精品国精品久久99热一| 国产精品狼人久久久久影院| 国产69精品久久久久久人妻精品| 2021精品国产综合久久| 伊人精品久久久久7777| 久久99国产精品久久99果冻传媒| 久久丝袜精品中文字幕| 波多野结衣中文字幕久久| 青春久久| 久久久久国产一级毛片高清板| 精品国产乱码久久久久久郑州公司 | 亚洲狠狠综合久久| 亚洲中文字幕久久精品无码喷水| 久久精品男人影院| 99精品久久久久中文字幕| 亚洲国产精品高清久久久| 久久男人中文字幕资源站| 久久综合丝袜日本网| 久久精品国产网红主播| 久久久www免费人成精品| 亚洲人成无码久久电影网站| 国产精品永久久久久久久久久| 久久91亚洲人成电影网站| 精品久久久无码人妻中文字幕豆芽| 精品国产乱码久久久久软件| 久久精品极品盛宴观看| 三级片免费观看久久| 中文字幕亚洲综合久久菠萝蜜| 久久精品中文字幕第23页| 久久影视综合亚洲| 一级a性色生活片久久无少妇一级婬片免费放 | 成人a毛片久久免费播放| 亚洲国产精品热久久|