How to deal with problems that require high precision ?

Revision en1, by im__skp, 2021-05-15 17:45:49

I was doing a problem in which you are given a number P and a number N. You have to find a number K such that K^N is equal to P.

CONSTRAINTS ARE : 1 ≤ n ≤ 200, 1 ≤ p < 10^101

PROBLEM LINK

The python code that got AC :

while True:
    try:
        n = int(input())
        p = int(input())
        print(round(p**(1/n)))

    except:
        break

Why do I have to use the round function why can't I use ceil or floor?

When should I use round?

These kinds of questions cost me a lot of WA's. Can someone tell me how to deal with these kinds of questions?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English im__skp 2021-05-15 17:48:39 1 Tiny change: ' lot of WA's.\nCan so' -> ' lot of WAs.\nCan so'
en1 English im__skp 2021-05-15 17:45:49 770 Initial revision (published)