1 条题解

  • 0
    @ 2026-2-3 10:42:50

    C :

    #include<stdio.h>
    int main()
    {
       int a,b,c,x,min=0;
       scanf("%d%d%d",&a,&b,&c);
       x=2;
       while(1){
       	  if(a%x==b%x&&a%x==c%x){    
             printf("%d\n",x);
             break;
          }
    	  x++; 
       }
       return 0;
    }
    

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	int a,b,c;
    	cin>>a>>b>>c;
    	for(int x=2;;x++){//两个分号中间是循环进行的条件,既然无条件进行,那就空着不写,但注意,必须是两个分号。
    		if(a%x==b%x&&c%x==b%x){
    			cout<<x;
    			return 0;//找到了满足条件的x,一定要立即结束程序或跳出循环!
    		}
    	}
    	return 0;
    }
    
    • 1

    信息

    ID
    75
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者