/***
* A + B Problem(解决A+B简单问题)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 658688 Accepted Submission(s): 205290
Problem Description
Calculate A + B.//计算A+B
Input //输入
Each line will contain two integers A and B. Process to end of file.
Output
For each case, output A + B in one line.
Sample Input
1 1
Sample Output
2
Author
HDOJ
*@author <a"283505495@qq.com">lxd</a>
*@version 1.0 2017-4-26 下午1:53:07
*@fileName P1000.java
*/
代码演示:
package ac;
import java.util.Scanner;
publicclass P1000 {
publicstaticvoidmain(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int a=sc.nextInt();
int b=sc.nextInt();
int sum=a+b;
System.out.println(sum);
}
}
}
运行结果:
p1001问题描述(Sum Problem):
/**
* Sum Problem(求和问题)
Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 470318 Accepted Submission(s): 118540
Problem Description
Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).
In this problem, your task isto calculate SUM(n) = 1 + 2 + 3 + ... + n.(求解1+....+n的和)
Input
The input will consist of a series of integers n, one integer per line.
Output
Foreachcase, output SUM(n) in one line, followed by a blank line.
32位的整数 也许n的值特别大
You may assume the result will be in the range of32-bit signed integer.
Sample Input
1100
Sample Output
15050
*@author <a"283505495@qq.com">lxd</a>
*@version 1.02017-4-26 下午2:09:34
*@fileName p1001.java
*/
/**
* A + B Problem II(A+B问题2-----利用大数进行解决)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 356144 Accepted Submission(s): 69087
Problem Description
I have a very simple problem for you. Given two integers A and B, your job isto calculate the Sum of A + B.
Input
(情况个数T)
The first line ofthe input contains an integer T(1<=T<=20) which means thenumberof test cases.
(这两个A、B数可能非常大)
Then T lines follow, each line consists of two positive integers, A and B. Notice thatthe integers are very large,
(比32位整数还要大)
that means you should not process them by using 32-bit integer.
(整数长度不要超过1000)
You may assume thelengthof each integer will not exceed 1000.
Output
For each test case, you should output two lines.
The first line is"Case #:", # means the number of the test case.
he second line isthe an equation "A + B = Sum", Sum means theresultof A + B.
Note there are some spaces int the equation. Output a blank line between two test cases.
Sample Input
212112233445566778899998877665544332211
Sample Output
Case 1:
1 + 2 = 3
Case 2:
112233445566778899 + 998877665544332211 = 1111111111111111110
*@author <a"283505495@qq.com">lxd</a>
*@version1.02017-4-26 下午2:16:06
*@fileName P1002.java
*/
/**
* Max Sum(求一个无序序列的最大和)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 242414 Accepted Submission(s): 57233
Problem Description
给定一个序列值,计算出此序列的最大和
Given a sequence a[1],a[2],a[3]......a[n], your job isto calculate the max sum of a sub-sequence.
For example, given (6,-1,5,4,-7), the max sum in this sequence is6 + (-1) + 5 + 4 = 14.
Input
The first line ofthe input contains an integer T(1<=T<=20) which means thenumberof test cases.
Then T lines follow, each line starts with a number N(1<=N<=100000),
then N integers followed(all the integers are between -1000and1000).
Output
For each test case, you should output two lines. The first line is"Case #:", # means the number of the test case.
最大和、起始位置、结束位置
The second line contains three integers, the Max Sum inthe sequence, the start position ofthe sub-sequence,
theend position ofthe sub-sequence. If there are more than one result, output thefirst one.
Output a blank line between two cases.
Sample Input
256 -154 -7706 -11 -67 -5
Sample Output
Case 1:
1414
Case 2:
716
*@author <a"283505495@qq.com">lxd</a>
*@version1.02017-4-26 下午3:02:59
*@fileName P1003.java
*/