mirror of
https://github.com/xlucn/PAT.git
synced 2026-09-22 17:54:01 +08:00
33 lines
467 B
C
33 lines
467 B
C
#include <stdio.h>
|
|
|
|
int iPrime(int N)
|
|
{
|
|
if(N == 0 || N == 1)
|
|
return 0;
|
|
for(int i = 2; i * i <= N; i++)
|
|
if(N % i == 0)
|
|
return 0;
|
|
return 1;
|
|
}
|
|
|
|
int Rev(int N, int D)
|
|
{
|
|
int Nrev;
|
|
for(Nrev = 0; N; N /= D)
|
|
{
|
|
Nrev *= D;
|
|
Nrev += N % D;
|
|
}
|
|
return Nrev;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
int N, D;
|
|
|
|
while(scanf("%d %d", &N, &D) == 2)
|
|
puts(iPrime(N) && iPrime(Rev(N, D)) ? "Yes" : "No");
|
|
|
|
return 0;
|
|
}
|