1 solutions

  • 0
    @ 2025-3-3 16:33:59

    C :

    #include<stdio.h>
    void main()
    {
    	int x; 
     	scanf("%d",&x); 
    	if(x != 1){ 
     	int i; 
     	int c = 0; //除了1很本身外的约数 
    	for(i = 2;i <= x/2 ;i++){ 
    		if(x % i == 0){ 
     			c++; 
     			printf("%d",i);
     			break; 
     		} 
    	} 
     
     	if(c == 0){ 
     		printf("Yes");
     	}
    	}
    }
    

    C++ :

    #include<iostream>
    #include<cmath>
    using namespace std;
    
    int main(){
    	
    	int n;
    	int min;
    	bool f;
    	
    	
    	f=true;
    	cin>>n;
    	
    	for(int i=2;i<=sqrt(n);i++){
    		if(n%i==0){
    			f=false;
    			min=i;
    			break;
    		}
    	}
    	
    	if(f==false || n==0 || n==1){
    		cout<<min<<endl;
    	}
    	else
    	{
    		cout<<"Yes"<<endl;
    	}
    }
    
    

    Python :

    n=int(input())
    f = 1
    for i in range(2,n-1,1):
        if n % i==0:
            f = 0
            break
    if f==1:
        print("Yes")
    else:
        print(i)
    
    
    • 1

    Information

    ID
    10837
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By