(SPOJ) 3830 - Soma - 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 qteNumeros = Integer.valueOf(tokenizer.nextToken());
int soma = 0;
for (int i = 0; i < qteNumeros; i++) {
line = br.readLine();
tokenizer = new StringTokenizer(line);
soma += Integer.valueOf(tokenizer.nextToken());
}
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 qteNumeros = Integer.valueOf(tokenizer.nextToken());
int soma = 0;
for (int i = 0; i < qteNumeros; i++) {
line = br.readLine();
tokenizer = new StringTokenizer(line);
soma += Integer.valueOf(tokenizer.nextToken());
}
System.out.println(soma);
return;
}
}
Comments
Post a Comment