需要住0 1不是素数
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
bool isPrim(int a)
{
if (a == 0 || a == 1)
return false;
bool re=true;
for (int i = 2; i <a; i++)
{
if (a%i == 0)
{
re = false;
break;
}
}
return re;
}
int main()
{
/*73 10
23 2
23 10
-2*/
int a = 0, b = 0;
cin >> a;
while (a > 0)
{
cin >> b;
if (isPrim(a))
{
int revers = 0;
while (a > 0)
{
revers = revers*b + a%b;
a = a / b;
}
if (isPrim(revers))
cout << "Yes\n";
else
cout << "No\n";
}
else
cout << "No\n";
cin >> a;
}
return 0;
}