• <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 閱讀(1104) 評論(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;
            }
            无码人妻久久一区二区三区免费| 久久免费观看视频| 亚洲精品tv久久久久| 无码8090精品久久一区| 久久精品国产网红主播| 久久香蕉综合色一综合色88| 国产精品久久久久久久人人看| 久久国产精品99精品国产| 色综合久久88色综合天天| 思思久久99热只有频精品66| 久久av高潮av无码av喷吹| 久久99精品久久久久久久久久| 久久久久久久91精品免费观看| 蜜臀av性久久久久蜜臀aⅴ麻豆| 久久久精品日本一区二区三区| 久久国产高清字幕中文| 久久婷婷激情综合色综合俺也去 | 99久久精品免费观看国产| 久久婷婷成人综合色综合| 久久久久亚洲精品天堂久久久久久 | 99精品国产在热久久无毒不卡 | 亚洲精品99久久久久中文字幕| 久久精品国产亚洲AV麻豆网站| 久久久久国产成人精品亚洲午夜| 久久婷婷五月综合色高清| 国产精品美女久久福利网站| 亚洲精品高清国产一久久| 久久久久亚洲AV片无码下载蜜桃| 伊人情人综合成人久久网小说| 精品久久久无码中文字幕天天| 国产欧美久久一区二区| 69国产成人综合久久精品| 久久久久99精品成人片直播| 色欲av伊人久久大香线蕉影院| 久久人人爽人人人人片av| 一本色道久久综合亚洲精品| 国产三级久久久精品麻豆三级| 欧美黑人激情性久久| 中文字幕日本人妻久久久免费| 久久午夜无码鲁丝片秋霞| 久久精品国产99久久久古代 |