程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> logging-Discrete Logging

logging-Discrete Logging

編輯:編程解疑
Discrete Logging

Description

Given a prime P, 2 <= P < 231, an integer B, 2 <= B < P, and an integer N, 1 <= N < P, compute the discrete logarithm of N, base B, modulo P. That is, find an integer L such that
BL == N (mod P)
Input

Read several lines of input, each containing P,B,N separated by a space.
Output

For each line print the logarithm on a separate line. If there are several, print the smallest; if there is none, print "no solution".
Sample Input

5 2 1
5 2 2
5 2 3
5 2 4
5 3 1
5 3 2
5 3 3
5 3 4
5 4 1
5 4 2
5 4 3
5 4 4
12345701 2 1111111
1111111121 65537 1111111111
Sample Output

0
1
3
2
0
3
1
2
0
no solution
no solution
1
9584351
462803587

最佳回答:


http://blog.csdn.net/bo_jwolf/article/details/15902319

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved