首页 > 其他 > 详细

杭电1395 利用同余手法提高效率

时间:2016-02-29 22:57:00      阅读:246      评论:0      收藏:0      [点我收藏+]

 

Problem Description
Give a number n, find the minimum x(x>0) that satisfies 2^x mod n = 1.
 

 

Input
One positive integer on each line, the value of n.
 

 

Output
If the minimum x exists, print a line with 2^x mod n = 1.

Print 2^? mod n = 1 otherwise.

You should replace x and n with specific numbers.
 

 

Sample Input
2 5
 

 

Sample Output
2^? mod 2 = 1 2^4 mod 5 = 1
如果不用同余手法处理 往往是会超时的
同余思想就是多个数乘积的余数等于各个数的余的乘积

杭电1395 利用同余手法提高效率

原文:http://www.cnblogs.com/z1141000271/p/5229163.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!