• <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 閱讀(1097) 評論(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国产精品二区不卡| 国产精品免费久久久久电影网| 久久精品一区二区三区中文字幕| 狠狠久久亚洲欧美专区| 99久久精品免费观看国产| 污污内射久久一区二区欧美日韩| 免费无码国产欧美久久18| 久久精品国产亚洲av麻豆蜜芽| 久久精品国产久精国产| 欧美精品丝袜久久久中文字幕| 久久久久亚洲av无码专区喷水| 久久国产高清一区二区三区| 久久中文字幕精品| 麻豆精品久久精品色综合| 麻豆精品久久久久久久99蜜桃| 99久久国产综合精品麻豆| 亚洲国产高清精品线久久| 麻豆精品久久久一区二区| 久久精品免费全国观看国产| 久久99热狠狠色精品一区| 亚洲AV无码久久精品蜜桃| 久久九色综合九色99伊人| 99久久精品国产麻豆| 久久亚洲精品无码AV红樱桃| 亚洲第一永久AV网站久久精品男人的天堂AV | 亚洲精品乱码久久久久久蜜桃不卡 | 一本久久a久久精品综合夜夜| 少妇久久久久久被弄到高潮| 久久亚洲欧美日本精品| 国产精品视频久久| 亚洲AV无码久久精品成人| 伊人色综合久久天天人守人婷| 99久久国产综合精品网成人影院| 国产∨亚洲V天堂无码久久久| 精品国产青草久久久久福利| 亚洲成av人片不卡无码久久| 久久精品国产一区二区三区不卡| 品成人欧美大片久久国产欧美...| 国产亚洲精品美女久久久| 国产精品美女久久久m| 久久亚洲AV成人出白浆无码国产|