Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double multiply(double m, int n){
- double ans = 1;
- for(int i=0; i<n; ++i){
- ans *= m;
- }
- return ans;
- }
- double findNthRootOfM(int n, long long m) {
- double low = 1, high = m, diff = 1e-7;
- while((high-low)>diff){
- double mid = (low + high)/2.0;
- if(multiply(mid, n)<m){
- low = mid;
- }
- else{
- high = mid;
- }
- }
- return high;
- }
Advertisement
Add Comment
Please, Sign In to add comment