#T465. 伪质数
伪质数
Description
Fermat's Little Theorem: If \( a \) is an integer and \( p \) is a prime number, then \( a^p - a \) is a multiple of \( p \), which can be expressed as \( a^p \equiv a \ (\text{mod} \ p) \). If \( a \) is not a multiple of \( p \), this theorem can also be written as \( a^{p-1} \equiv 1 \ (\text{mod} \ p) \), a form that is more commonly used. However, there exist some composite numbers \( p \) that satisfy \( a^p \equiv a \ (\text{mod} \ p) \) for specific values of \( a \). Such numbers are called pseudoprimes to base \( a \).
Given \( 2 \leq p \leq 10,000,000,000 \) and \( 1 < a < p \), determine whether \( p \) is a pseudoprime to base \( a \).
Input Format
Each test case consists of multiple sets of data. Each set of data occupies one line and contains \( p \) and \( a \), separated by a space. The input ends with two 0s.
Output Format
For each set of data, output "yes" if \( p \) is a pseudoprime to base \( a \), otherwise output "no". Each result should be on a separate line.
```input1 10 3 341 2 341 3 0 0 ``` ```output1 no yes no ``` ## 翻译结果CodesOnline