UVa 113 - Power of Cryptography

113 - Power of Crytography

 * http://acm.uva.es/p/v1/113.html

Summary
Given p and n, calculate $$\sqrt[n]{p}$$. We can solve this by using Logarithms.

Explanation
Recall that in Logarithms:

$$k^n = p$$

is equivalent to

$$\ln{ k^n } = \ln{ p }$$

which is simply

$$n \ln{ k }= \ln{ p }$$

or

$$\ln{ k }= \frac{\ln{ p }}{n}$$

thus k is:

$$k = e^{(\frac{\ln{ p}}{n})}$$

Input
2 16 3 27 7 4357186184021382204544

Output
4 3 1234