ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1000. A+B Problem

import java.io.*;
import java.util.*;

public class A_B_Problem {
    public static void main(String[] args) throws Exception
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        int A = Integer.parseInt(reader.readLine()), B = Integer.parseInt(reader.readLine());
        out.println(A + B);

        out.flush();
    }
}
BufferedReader faster, and consumes less memory, what is the problem?
See the input format carefully
Andrew Sboev
"Numbers are located at the same line. So, first call of readLine() give you "a b", and second - null."

Потому что по условию задачи входные данные должны быть вида - "5 _ 1", а, если пользуешься ReadLine - то у тебя будет так,
5
1

а ввод вида "5 1" возможен при помощи сканнера

Edited by author 28.10.2015 13:28