HDU 1905(搜索题,逐次平方法)
来源:互联网 发布:管家婆软件销售怎么 编辑:程序博客网 时间:2024/04/29 12:44
Pseudoprime numbers
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 405 Accepted Submission(s): 157
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.
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 210 3341 2341 31105 21105 30 0
Sample Output
nonoyesnoyesyes
- HDU 1905(搜索题,逐次平方法)
- 利用逐次平方法快速求幂
- 逐次逼近法
- hdu 2035 反复平方法
- HDU 5057-平方分割(分块)
- 逐次代入法求解非线性方程
- 机器学习之逐次下降法
- 最小二乘法(最小平方法)
- 最小二乘法(最小平方法)
- hdu 5057(平方分割)
- HDU 1175(搜索题,BFS)
- HDU 2102(搜索题,BFS)
- HDU 1180(搜索题,BFS)
- HDU 2612(搜索题,BFS)
- HDU 1312(搜索题,DFS)
- HDU 1241(搜索题,DFS)
- HDU 2199(搜索题,二分)
- HDU 2899(搜索题,二分)
- 系统蓝屏代码表
- 模仿python SocketServer.py写的一个socket服务类 2
- (转)如何在没有文档的情况下使用CView及其派生类
- 《Windows核心编程》---堆管理函数
- Linux主要shell命令详解
- HDU 1905(搜索题,逐次平方法)
- Windows系统蓝屏代码表全解!总有一个是你的蓝屏代码!
- WINDOWS下搭建PHP+APACHE开发环境
- 开发时间过程中遇到的一些问题
- 为RHEL5开启telnet服务
- ubuntu 10.04 bug:svn: MKACTIVITY of '/svn/!svn/act/421fae24-46c0-4787-ae8b-192023cf961e': authorization failed: Could not authen
- 架构师的行为准则(二)
- Linux下使用enca查看文件编码并转换
- mvc