编程介的小学生
2019-03-08 23:00伪素数的判断问题,基于进制的转换,采用C语言实现的办法怎么做到
Problem Description
Fermat's theorem states that for any prime number p and for any integer a > 1, a^p == a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (but not very many) non-prime values of p, known as base-a pseudoprimes, have this property for some a. (And some, known as Carmichael Numbers, are base-a pseudoprimes for all a.)
Given 2 < p ≤ 1,000,000,000 and 1 < a < p, determine whether or not p is a base-a pseudoprime.
Input
Input contains several test cases followed by a line containing "0 0". Each test case consists of a line containing p and a.
Output
For each test case, output "yes" if p is a base-a pseudoprime; otherwise output "no".
Sample Input
3 2
10 3
341 2
341 3
1105 2
1105 3
0 0
Sample Output
no
no
yes
no
yes
yes
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- C语言编程题 函数题 编写一个函数,判断参数n。
- c语言
- 1个回答
- C语言判断素数 大一实验题,谢谢大家!
- c语言
- 1个回答
- 求大佬帮忙看一下我用C语言写的编程题代码有什么问题
- c语言
- 2个回答
- C语言 判断输入数字是否为素数 输入1到17判断都是正确的(只试到17) 但是输入9判断结果是“9是素数” 而且就9这一个数字这样 求解??
- c语言
- 1个回答
- 寻找素数,遍历 判断余数为0时出错,明明能整除2,却会推到后面的数才判断出
- c语言
- 2个回答