4 solutions

  • 0
    @ 2022-3-2 16:08:27
    #include<iostream>
    #include<cmath>
    #include<cstdio>
    using namespace std;
    #define ll long long
    
    bool isPrime(ll n){
    	if(n==2)	return true;
    	for(ll i=2;i*i<=n;i++){
    		if(n%i==0)
    			return false;
    	}
    	return true;
    }
    
    int main(){
    	int t;
    	ll x,y;
    
    	scanf("%d",&t);
    	while(t--){
    		scanf("%lld%lld",&x,&y);
    
    		if(isPrime(x*y))
    			cout<<"YES\n";
    		else
    			cout<<"NO\n";
    	}
    
    	return 0;
    }
    

    Information

    ID
    22
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    723
    Accepted
    104
    Uploaded By