From f0017b2fa642ed8ed65550a8162e4ed19b325b6e Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Sat, 18 Nov 2017 23:11:45 +0100 Subject: Problema 370 resuelto. --- AceptaElReto/src/problemas/Problema370.java | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 AceptaElReto/src/problemas/Problema370.java 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"; + } +} -- cgit v1.2.1