UVa 113

From Algorithmist
Jump to navigation Jump to search

113 - Power of Crytography[edit]

Summary[edit]

Given p and n, calculate . We can solve this by using Logarithms.

Explanation[edit]

Recall that in Logarithms:

is equivalent to

which is simply

or

thus k is:

Notes[edit]

  • Double should be enough.

Input[edit]

2
16
3
27
7
4357186184021382204544

Output[edit]

4
3
1234

Solution[edit]