(SPOJ) 1330 - Meteoros - Solução
import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
void processa() throws NumberFormatException, IOException {
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int contador = 0;
while ((line = br.readLine()) != null) {
StringTokenizer tokenizer = new StringTokenizer(line);
int x1 = Integer.valueOf(tokenizer.nextToken());
int y1 = Integer.valueOf(tokenizer.nextToken());
int x2 = Integer.valueOf(tokenizer.nextToken());
int y2 = Integer.valueOf(tokenizer.nextToken());
if (x1 == 0 && x2 == 0 && y1 == 0 && y2 == 0) {
return;
}
contador++;
System.out.println("Teste " + contador);
line = br.readLine();
tokenizer = new StringTokenizer(line);
int qteMeteoros = Integer.valueOf(tokenizer.nextToken());
int soma = 0;
for (int i = 0; i < qteMeteoros; i++) {
line = br.readLine();
tokenizer = new StringTokenizer(line);
int x = Integer.valueOf(tokenizer.nextToken());
int y = Integer.valueOf(tokenizer.nextToken());
if (x >= x1 && x <= x2 && y <= y1 && y >= y2) {
soma += 1;
}
}
System.out.println(soma);
System.out.println();
}
return;
}
}
import java.util.*;
class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
Main processando = new Main();
processando.processa();
System.exit(0);
}
void processa() throws NumberFormatException, IOException {
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int contador = 0;
while ((line = br.readLine()) != null) {
StringTokenizer tokenizer = new StringTokenizer(line);
int x1 = Integer.valueOf(tokenizer.nextToken());
int y1 = Integer.valueOf(tokenizer.nextToken());
int x2 = Integer.valueOf(tokenizer.nextToken());
int y2 = Integer.valueOf(tokenizer.nextToken());
if (x1 == 0 && x2 == 0 && y1 == 0 && y2 == 0) {
return;
}
contador++;
System.out.println("Teste " + contador);
line = br.readLine();
tokenizer = new StringTokenizer(line);
int qteMeteoros = Integer.valueOf(tokenizer.nextToken());
int soma = 0;
for (int i = 0; i < qteMeteoros; i++) {
line = br.readLine();
tokenizer = new StringTokenizer(line);
int x = Integer.valueOf(tokenizer.nextToken());
int y = Integer.valueOf(tokenizer.nextToken());
if (x >= x1 && x <= x2 && y <= y1 && y >= y2) {
soma += 1;
}
}
System.out.println(soma);
System.out.println();
}
return;
}
}
Comments
Post a Comment