#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
ll bigmod(ll a, ll b, ll m)
{
if(b == 0)
return 1;
ll x = bigmod(a, b/2, m);
x = (x*x)%m;
if(b%2 == 1)
x = (x*a)%m;
return x;
}
int prime(ll p)
{
ll d = sqrt(p), i;
for(i=2;i<=d;i++)
{
if(p%i == 0)
{
return 0;
break;
}
}
return 1;
}
int main()
{
ll n, p;
while(cin >> p >> n && p > 0 && n > 0)
{
int k = prime(p);
if(k == 1)
{
cout << "no" << endl;
continue;
}
ll t = bigmod(n, p, p);
if(t == n)
cout << "yes" << endl;
else
cout << "no" << endl;
}
return 0;
}
#define ll unsigned long long int
using namespace std;
ll bigmod(ll a, ll b, ll m)
{
if(b == 0)
return 1;
ll x = bigmod(a, b/2, m);
x = (x*x)%m;
if(b%2 == 1)
x = (x*a)%m;
return x;
}
int prime(ll p)
{
ll d = sqrt(p), i;
for(i=2;i<=d;i++)
{
if(p%i == 0)
{
return 0;
break;
}
}
return 1;
}
int main()
{
ll n, p;
while(cin >> p >> n && p > 0 && n > 0)
{
int k = prime(p);
if(k == 1)
{
cout << "no" << endl;
continue;
}
ll t = bigmod(n, p, p);
if(t == n)
cout << "yes" << endl;
else
cout << "no" << endl;
}
return 0;
}
Comments
Post a Comment