(SPOJ) 12993 - Auto Estrada - 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));
line = br.readLine();
StringTokenizer tokenizer = new StringTokenizer(line);
int comprimento = Integer.valueOf(tokenizer.nextToken());
int soma = 0;
line = br.readLine();
for (int i = 0; i < comprimento; i++) {
if (line.charAt(i) == 'D') {
}
else if (line.charAt(i) == 'A') {
soma += 1;
}
else if (line.charAt(i) == 'P') {
soma += 2;
}
else if (line.charAt(i) == 'C') {
soma += 2;
}
}
System.out.println(soma);
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));
line = br.readLine();
StringTokenizer tokenizer = new StringTokenizer(line);
int comprimento = Integer.valueOf(tokenizer.nextToken());
int soma = 0;
line = br.readLine();
for (int i = 0; i < comprimento; i++) {
if (line.charAt(i) == 'D') {
}
else if (line.charAt(i) == 'A') {
soma += 1;
}
else if (line.charAt(i) == 'P') {
soma += 2;
}
else if (line.charAt(i) == 'C') {
soma += 2;
}
}
System.out.println(soma);
return;
}
}
Comments
Post a Comment