added precision_root_algo

This commit is contained in:
Deepak 2017-10-02 13:00:39 +05:30 committed by GitHub
parent 8b29c6ca1d
commit 355d4c1fee

28
Misc/root_precision Normal file
View File

@ -0,0 +1,28 @@
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int N = scn.nextInt();
int P = scn.nextInt();
System.out.println(squareRoot(N, P));
}
public static double squareRoot(int N, int P) {
double sqrt = 0;;
// Write your code here
double root = Math.pow(N, 0.5);
int pre = (int) Math.pow(10, P);
root = root * pre;
sqrt = (int)root;
return (double)sqrt/pre;
}
}