0
点赞
收藏
分享

微信扫一扫

1001. A+B Format (20)


1001. A+B Format (20)


时间限制


400 ms



内存限制



65536 kB



代码长度限制



16000 B



判题程序



Standard



作者



CHEN, Yue


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 9


Sample Output


-999,991



求两数相加后,用三位一个逗号的写出来



时间

结果

得分

题目

语言

用时(ms)

内存(kB)

用户

7月17日

20:56

答案正确

​​20​​

​​1001​​

​​C++ (g++ 4.7.2)​​

1

308

​​datrilla​​

测试点

测试点

结果

用时(ms)

内存(kB)

得分/满分

0

答案正确

1

180

9/9

1

答案正确

1

180

1/1

10

答案正确

1

308

1/1

11

答案正确

1

180

1/1

2

答案正确

1

308

1/1

3

答案正确

1

180

1/1

4

答案正确

1

308

1/1

5

答案正确

1

256

1/1

6

答案正确

1

256

1/1

7

答案正确

1

180

1/1

8

答案正确

1

308

1/1

9

答案正确

1

308

1/1

#include 


#include


using namespace std;
void pprint(int x)
{
cout<<",";
cout<

>a>>b;
a+=b;
if(abs(a)<1000)
cout<












第一次写个java,没有系统学,就用写c的思路下去,测出来的差距感受感受


评测结果


时间
结果
得分
题目
语言
用时(ms)
内存(kB)
用户


9月22日 09:08

答案正确

20

1001

Java (javac 1.6.0)

81

10668

datrilla



测试点


测试点
结果
用时(ms)
内存(kB)
得分/满分



0

答案正确

81

10520

9/9



1

答案正确

80

10480

1/1



10

答案正确

81

10372

1/1



11

答案正确

80

10380

1/1



2

答案正确

79

10416

1/1



3

答案正确

80

10304

1/1



4

答案正确

80

10480

1/1



5

答案正确

80

10400

1/1



6

答案正确

80

10416

1/1



7

答案正确

80

10508

1/1



8

答案正确

80

10376

1/1



9

答案正确

80

10668

1/1




import java.util.*;
public class Main {
public static void pprint(int x)
{
System.out.print(","+x/100);
x%=100;
System.out.print(x/10+""+x%10);
}
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
int a=in.nextInt();
int b=in.nextInt();
in.close();
a+=b;
if(Math.abs(a)<1000)
System.out.print(a);
else if(Math.abs(a)<1000000)
{
System.out.print(a/1000);
pprint(Math.abs(a)%1000);
}else
{
System.out.print(a/1000000);
a=Math.abs(a)%1000000;
pprint(a/1000);
pprint(a%1000);
}
System.out.println();
}

}


举报

相关推荐

0 条评论