diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2017-12-02 17:52:54 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2017-12-02 17:52:54 +0100 |
commit | 3f7848dc0abda4f164a964cc7ceeac40bd602016 (patch) | |
tree | 95310391fb0d9361b6a8adaaf5b79f97c4c77019 | |
parent | 71911c556138108d554762f9c3ae17502aedcd4d (diff) | |
download | AceptaElReto-3f7848dc0abda4f164a964cc7ceeac40bd602016.tar.gz AceptaElReto-3f7848dc0abda4f164a964cc7ceeac40bd602016.zip |
Problema 402 (Dimensiones del puzzle) subido, out of time exception.
-rw-r--r-- | AceptaElReto/src/problemas/Problema402DimensionesDelPuzzle.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/AceptaElReto/src/problemas/Problema402DimensionesDelPuzzle.java b/AceptaElReto/src/problemas/Problema402DimensionesDelPuzzle.java new file mode 100644 index 0000000..3a68741 --- /dev/null +++ b/AceptaElReto/src/problemas/Problema402DimensionesDelPuzzle.java @@ -0,0 +1,31 @@ +package problemas; + +public class Problema402DimensionesDelPuzzle { + + static java.util.Scanner in; + + public static void main(String args[]) { + in = new java.util.Scanner(System.in); + int caso; + while ( true ) { + caso = in.nextInt(); + if ( caso == 0 ) { + break; + } + System.out.println(casoDePrueba(caso)); + } + } + + public static int casoDePrueba(int caso) { + int lado = (int) Math.sqrt(caso); + while ( caso % lado != 0 ) { + lado++; + } + return lado; + } + + /*public static int findLowestNextDivisorInRange( int lado, int caso ) { + + }*/ + +} |