Java
Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 100 megabytes
Time limit: 1.0 seconds
Output: Standard Output (stdout)
Memory limit: 100 megabytes
Time limit: 1.0 seconds
Note: Your class must be called Main
.
Example
Adding two numbers. Numbers will be space separated on a single line.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(sc.nextInt() + sc.nextInt());
}
}
Note
On problems with larger inputs, Scanner
may be too slow. In such cases, we recommend using BufferedReader
and StringTokenizer
instead. For example:
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
System.out.println(Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken()));
}
}
Submit
- Go to the submit tab and upload the addition program above by copy-pasting and selecting Java in the language dropdown.
-
Sample Input 1
3 4
Sample Output 1
7