• <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;
            }
            国产日韩久久久精品影院首页| 久久性精品| 99国产欧美精品久久久蜜芽| 国产精品一久久香蕉国产线看观看 | 久久久精品人妻无码专区不卡| 亚洲国产香蕉人人爽成AV片久久 | 伊人精品久久久久7777| 久久国产精品77777| 亚洲国产精品嫩草影院久久| 国内精品久久久久影院优| 久久久久久久免费视频| 久久精品国产精品青草| 亚洲午夜久久久影院| 久久人人爽人人精品视频| 九九精品99久久久香蕉| 久久久黄片| 丰满少妇人妻久久久久久4| 无码精品久久久天天影视| 久久国产亚洲精品| 欧美性大战久久久久久| 国产—久久香蕉国产线看观看| 97精品国产97久久久久久免费 | 日韩一区二区三区视频久久| 国产精品久久久久…| 久久精品国产第一区二区三区| 免费精品久久天干天干| 亚洲午夜久久久| 久久久久久久久久免免费精品| 国产精品永久久久久久久久久| 91久久九九无码成人网站| 久久青草国产精品一区| 精品乱码久久久久久久| 久久精品一区二区| 久久亚洲精品中文字幕三区| 久久久久久综合一区中文字幕| 久久精品一区二区| 国产一区二区精品久久岳| 久久人妻少妇嫩草AV无码蜜桃 | 狠狠精品久久久无码中文字幕 | 久久久久久曰本AV免费免费| 久久天天躁夜夜躁狠狠躁2022|