这题其实还是很简单的

首先你要了解以下公式

A(Prime) * B(Prime) = C(NotPrime)
A(Prime) * B(NotPrime) = C(如果AB互质则Prime否则NotPrime)
A(NotPrime) * B(NotPrime) = C(NotPrime)

上代码

#include <iostream>
#include <algorithm>
#define int long long
using namespace std ;

int t, a, b ;
bool prime(int x)
{
    if (x == 1) return false ;
    for (int i = 2 ; i <= x / i ; i++)
    {
        if (x % i == 0) return false ;
    }
    return true ;
}
signed main()
{
    cin >> t ;
    while (t--)
    {
        cin >> a >> b ;
        bool fa = prime(a) ;
        bool fb = prime(b) ;


        if (fa == fb)
        {
            cout << "NO" << endl ;
        }
        else
        {
            if (__gcd(a, b) == 1) cout << "YES" << endl ;
            else cout << "NO" << endl ;
        }
    }
    
    return 0 ;
}