Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- We need to find an integer x such that x^n = m (because nth root of m means raising the root to power n gives back m).
- Since x^n increases as x increases, we can binary search x in the range [0, m].
- For each mid, compute mid^n using pow(mid, n) and compare it with m.
- If mid^n == m return mid, otherwise adjust the search space.
- If no such integer exists, return -1.
- """
- class Solution:
- def nthRoot(self, n, m):
- l,r=0,m
- while l<=r:
- mid=(l+r)//2
- val=pow(mid,n)
- if val==m:
- return mid
- elif val>m:
- r=mid-1
- else:
- l=mid+1
- return -1
Advertisement
Comments
-
- ⭐ Changelly Profit Exploit Documentation ⭐
- https://docs.google.com/document/d/1MzFoZVdCI0pv3Bkf4dAe-WjfaXKLNbI90hzSGKBqn9M/edit?usp=cragnibbyg
- This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
- The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader.
- Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment