import java.util.Scanner;
/**
 * Solucion al Problema: 1354 – IP Checking [http://lightoj.com/]
 * 
 * @author BreakDark (Jhonny Monrroy)
 * @version 1.0 14 ago. 2016
 */
// Accepted!!! xD
public class Main {
 public static void main(String[] args) {
  Scanner Lee; // para leer los datos de entrada
  int T; // numero de casos de prueba
  String ipDecimal, ipBinario;
  // AQUI INICIA EL PROGRAMA
  Lee = new Scanner(System.in);
  T = Lee.nextInt();
  for (int i = 1; i <= T; i++) {
   ipDecimal = Lee.next();
   ipBinario = Lee.next();
   String aux = Short.parseShort(ipBinario.substring(0, 8), 2) + ".";
   aux += Short.parseShort(ipBinario.substring(9, 17), 2) + ".";
   aux += Short.parseShort(ipBinario.substring(18, 26), 2) + ".";
   aux += Short.parseShort(ipBinario.substring(27), 2);
   System.out.println("Case " + i + ": " + (ipDecimal.equals(aux) ? "Yes" : "No"));
  }
  Lee.close();
 }
}
Blog dedicado a la publicación de artículos, programas propios, traducciones de Roms de Nes, super Nes y mas, y alguno que otro artículo sobre tecnologia.
Thursday, September 15, 2016
Solucion al Problema: 1354 – IP Checking [http://lightoj.com/] con Java
Para ver el link del problema Click aqui
Subscribe to:
Post Comments (Atom)
 
 
No comments:
Post a Comment