Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).
Input
Each input file contains one test case. Each case contains a pair of integers a and b where -1000000 <= a, b <= 1000000. The numbers are separated by a space.
Output
For each test case, you should output the sum of a and b in one line. The sum must be written in the standard format.
Sample Input-1000000 9Sample Output
-999,991
import java.text.DecimalFormat; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String input = scanner.nextLine(); String[] arr = input.split(" "); int result = Integer.parseInt(arr[0]) + Integer.parseInt(arr[1]); DecimalFormat df = new DecimalFormat(",###"); System.out.println(df.format(result)); } }
评测结果
时间 | 结果 | 得分 | 题目 | 语言 | 用时(ms) | 内存(kB) | 用户 |
---|---|---|---|---|---|---|---|
4月30日 09:36 | 答案正确 | 20 | 1001 | Java (javac 1.6.0) | 81 | 10516 | zspring |
测试点
测试点 | 结果 | 用时(ms) | 内存(kB) | 得分/满分 |
---|---|---|---|---|
0 | 答案正确 | 79 | 10508 | 9/9 |
1 | 答案正确 | 81 | 10332 | 1/1 |
10 | 答案正确 | 79 | 10332 | 1/1 |
11 | 答案正确 | 81 | 10492 | 1/1 |
2 | 答案正确 | 80 | 10336 | 1/1 |
3 | 答案正确 | 79 | 10436 | 1/1 |
4 | 答案正确 | 80 | 10376 | 1/1 |
5 | 答案正确 | 80 | 10328 | 1/1 |
6 | 答案正确 | 79 | 10360 | 1/1 |
7 | 答案正确 | 80 | 10352 | 1/1 |
8 | 答案正确 | 80 | 10516 | 1/1 |
9 | 答案正确 | 80 | 10464 | 1/1 |