UVa 113

From Algorithmist

Jump to: navigation, search

Contents

[edit] 113 - Power of Crytography

[edit] Summary

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

[edit] Explanation

Recall that in Logarithms:

kn = p

is equivalent to

lnkn = lnp

which is simply

nlnk = lnp

or

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

thus k is:

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

[edit] Notes

  • Double should be enough.

[edit] Input

2
16
3
27
7
4357186184021382204544

[edit] Output

4
3
1234
Personal tools