From 355d4c1fee55b176f8309b1558b69f858329b8f5 Mon Sep 17 00:00:00 2001 From: Deepak Date: Mon, 2 Oct 2017 13:00:39 +0530 Subject: [PATCH] added precision_root_algo --- Misc/root_precision | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Misc/root_precision diff --git a/Misc/root_precision b/Misc/root_precision new file mode 100644 index 00000000..1b5e9547 --- /dev/null +++ b/Misc/root_precision @@ -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; + } +}