diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2017-11-18 23:11:45 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2017-11-18 23:11:45 +0100 |
commit | f0017b2fa642ed8ed65550a8162e4ed19b325b6e (patch) | |
tree | 61d74c76f07af78943648516e05bf2de61c2eb9c | |
parent | faff6bab7457d0d3192f2d445a33bea97087793f (diff) | |
download | AceptaElReto-f0017b2fa642ed8ed65550a8162e4ed19b325b6e.tar.gz AceptaElReto-f0017b2fa642ed8ed65550a8162e4ed19b325b6e.zip |
Problema 370 resuelto.
-rw-r--r-- | AceptaElReto/src/problemas/Problema370.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/AceptaElReto/src/problemas/Problema370.java b/AceptaElReto/src/problemas/Problema370.java new file mode 100644 index 0000000..48c5dce --- /dev/null +++ b/AceptaElReto/src/problemas/Problema370.java @@ -0,0 +1,33 @@ +package problemas;
+
+public class Problema370 {
+
+ static java.util.Scanner in;
+
+ public static void main(String args[]) {
+ in = new java.util.Scanner(System.in);
+
+ int numCasos = Integer.parseInt(in.nextLine());
+ for (int i = 0; i < numCasos; i++) {
+ String llave = in.nextLine();
+ System.out.println(casoDePrueba(llave));
+ }
+ }
+ public static String casoDePrueba(String llave) {
+ int calibreUno = Integer.parseInt(llave.substring(0, llave.indexOf('-')));
+ int calibreDos = Integer.parseInt(llave.substring(llave.indexOf('-') + 1));
+ if ( calibreUno - calibreDos == 1 ) {
+ if ( calibreDos % 2 == 0 ) {
+ return "SI";
+ }
+ return "NO";
+ }
+ if ( calibreDos - calibreUno == 1 ) {
+ if ( calibreUno % 2 == 0 ) {
+ return "SI";
+ }
+ return "NO";
+ }
+ return "NO";
+ }
+}
|