(SPOJ) 19987 - Ansiedade - 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 {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String line = "";
int contaTriagem = 0;
while ((line = br.readLine()) != null) {
int contaSim = 0;
for (int i = 0; i < 10; i++) {
if (line.equals("sim")) {
contaSim++;
}
if (i < 9) {
line = br.readLine();
}
}
if (contaSim >= 2) {
contaTriagem++;
}
}
bw.write(contaTriagem + "\n");
bw.flush();
bw.close();
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 {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String line = "";
int contaTriagem = 0;
while ((line = br.readLine()) != null) {
int contaSim = 0;
for (int i = 0; i < 10; i++) {
if (line.equals("sim")) {
contaSim++;
}
if (i < 9) {
line = br.readLine();
}
}
if (contaSim >= 2) {
contaTriagem++;
}
}
bw.write(contaTriagem + "\n");
bw.flush();
bw.close();
return;
}
}
Comments
Post a Comment