A + B Problem(1000)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 355051 Accepted Submission(s): 110841
Problem Description
Calculate
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
Sample Output
2
題意:每一行輸入包含兩個整數a和b,每個案例輸出a+b的值,在一行;
詳見代碼,
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
sum=a+b;
printf("%d\n",sum);
}
return 0;
}
Sum Problem(1001)
Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 237995 Accepted Submission(s): 58229
Problem Description
Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
Input
The input will consist of a series of integers n, one integer per line.
Output
For each case,
output SUM(n) in one line,
followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.
Sample Input
Sample Output
題意:每行將輸入一個整數n,對於每個案例,輸出SUM(n) = 1 + 2 + 3 + ... + n<求1到n的和> 在一行,緊隨其后的是一個空行。
其他的就沒什么可以注意的了。
詳見代碼:
#include<stdio.h>
int main()
{
int n,i,sum;
while(scanf("%d",&n)!=EOF)
{
for(sum=0,i=0;i<=n;i++)
sum=sum+i;
printf("%d\n\n",sum);
}
return 0;
}
A+B for Input-Output Practice (I)(1089)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 68193 Accepted Submission(s): 37929
Problem Description
Your task is to Calculate a + b. Too easy?! Of course! I specially designed the problem for acm beginners. You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.
Input
The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.
Output
For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
Sample Input
Sample Output
6
30
題意:輸入整數a和b,用空格分隔,每行一對整數。對於每一對輸入整數a和b你應該輸出他們的總和,輸入a和b占在一行,輸出占一行。
貌似和1000是一樣的,o(∩_∩)o 哈哈!
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
sum=a+b;
printf("%d\n",sum);
}
return 0;
}
A+B for Input-Output Practice (II)(1090)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 51355 Accepted Submission(s): 33780
Problem Description
Your task is to Calculate a + b.
Input
Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, separated by a space, one pair of integers per line.
Output
For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
Sample Input
Sample Output
6
30
題意:輸入包含一個整數N在第一行,然后有N數據。每一行包含一對整數a和b,用空格分隔,每行一對整數。
對於每一對輸入整數a和b你應該輸出的總和,a和b在一行,輸出輸入各占一行。
比較1089,在1089的基礎上多了一個控制輸入測試的組數N,其他的一樣。有木有。
詳見代碼;
#include<stdio.h>
int main()
{
int a,b,t,sum;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&a,&b);
sum=a+b;
printf("%d\n",sum);
}
return 0;
}
A+B for Input-Output Practice (III)(1091)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 60600 Accepted Submission(s): 31168
Problem Description
Your task is to Calculate a + b.
Input
Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line.
A test case containing 0 0 terminates the input and this test case is not to be processed.
Output
For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
Sample Input
Sample Output
6
30
題意:輸入包含多個測試用例。每個測試用例包含一對整數a和b,一對整數占一行。當輸入測試用例為0 0時,終止輸入和測試用例是不被處理。對於每一對輸入整數a和b你應該輸出他們的總和,a和b在一行,輸出在一行。
比較1091,不一樣的地方就是結束輸入的條件不一樣,其他的不變,有木有。
詳見代碼:
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
if(a==0&&b==0)break;
sum=a+b;
printf("%d\n",sum);
}
return 0;
}
A+B for Input-Output Practice (IV)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 53974 Accepted Submission(s): 28848
Problem Description
Your task is to Calculate the sum of some integers.
Input
Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.
Output
For each group of input integers you should output their sum in one line, and with one line of output for each line in input.
Sample Input
Sample Output
10
15
題意:輸入包含多個測試用例。每個測試用例包含一個整數N,然后在同一行輸入N個整數,。當測試用例是0時,終止輸入和測試用例是不被處理。每組輸出整數之和占一行,即,一行輸入一行輸出。
比較前面幾題,這題稍微有點區別但變幻不大,N用來控制整數的個數。然后最后以0結束測試,
詳見代碼:
#include<stdio.h>
int main()
{
int a[100],t,i,sum;
while(scanf("%d",&t)!=EOF)
{
if(t==0)
break;
sum=0;
for(i=1;i<=t;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("%d\n",sum);
}
return 0;
}
A+B for Input-Output Practice (V)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 39483 Accepted Submission(s): 26698
Problem Description
Your task is to calculate the sum of some integers.
Input
Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.
Output
For each group of input integers you should output their sum in one line, and with one line of output for each line in input.
Sample Input
Sample Output
10
15
題意:輸入包含一個整數N在第一行,然后有N行測試用例,每一行都始於一個整數M,然后有M整數在同一個行。
每組輸出整數之和且輸出占一行,一行輸入一行輸出。
反思:是不是前兩題的集合體哈,再仔細看看就知道了。有木有!
詳見代碼:
#include<stdio.h>
int main()
{
int a[100],t,i,p,sum;
scanf("%d",&p);
while(p--)
{
scanf("%d",&t);
if(t==0)
break;
sum=0;
for(i=1;i<=t;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("%d\n",sum);
}
return 0;
}
A+B for Input-Output Practice (VI)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 37174 Accepted Submission(s): 25051
Problem Description
Your task is to calculate the sum of some integers.
Input
Input contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.
Output
For each test case you should output the sum of N integers in one line, and with one line of output for each line in input.
Sample Input
Sample Output
10
15
這題就不要在啰嗦的在寫題意了吧,貌似和上面的題目太像了,,,,
o(∩_∩)o 哈哈
詳見代碼:
#include<stdio.h>
int main()
{
int a[100],t,i,sum;
while(scanf("%d",&t)!=EOF)
{
sum=0;
for(i=1;i<=t;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("%d\n",sum);
}
return 0;
}
看到這里我只想說,大家做題時候,代碼寫的格式一定要規范,最好就是形式統一,該空的時候就空格,不然代碼都一個水平面就美觀了,而且以后比賽的時候你還有2個隊友,讓他們給你檢查錯誤的話,你的代碼又不整潔,那么效率肯定不會高的,而且會有厭煩的心態,那就更好了,所以大家以后寫代碼盡量規范一點。就是這樣了!
A+B for Input-Output Practice (VII)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 36617 Accepted Submission(s): 24438
Problem Description
Your task is to Calculate a + b.
Input
The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.
Output
For each pair of input integers a and b you should output the sum of a and b, and followed by a blank line.
Sample Input
Sample Output
6
30
題意:輸入2個整數a和b,用空格分隔,每行一對整數。對於每一對輸入整數a和b你應該輸出他們的總和,a和b,身后跟着一個空行。
是不是又忘記空行了,輸出的時候,這次又是中間再空一行哦,所以做題的時候一定要先看清楚題目的具體要求在動手編程,不然只會白白丟分!
詳見代碼:
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
sum=a+b;
printf("%d\n\n",sum);
}
return 0;
}
終於快結束了,,,,,,搞得好辛苦,大家一定要認真對待啊!
A+B for Input-Output Practice (VIII)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 78908 Accepted Submission(s): 24263
Problem Description
Your task is to calculate the sum of some integers.
Input
Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.
Output
For each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.
Sample Input
3
4 1 2 3 4
5 1 2 3 4 5
3 1 2 3
Sample Output
10
15
6
題意:輸入包含一個整數N在第一行,然后有N行測試數據。每一行都開始都有一個整數M,然后后面有M個整數在同一行。
每組輸出整數之和,輸出占一行,你必須注意,輸出,每行之間有一個空行。
我只能說這題就是上面幾道題目的大集合吧,所以是不是很簡單呢。哈哈,所以對於acm的輸入輸出是不是有所了解了呢,
對!就是那么簡單!so easy! o(∩_∩)o 那么,,,
還
是先看代碼吧,
#include<stdio.h>
int main()
{
int a[100],t,i,p,sum;
scanf("%d",&p);
while(p--)
{
scanf("%d",&t);
sum=0;
for(i=1;i<=t;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("%d\n",sum);
if(p)//中間空行用
printf("\n");
}
return 0;
}
到現在為止,你已經學會acm的簡單輸入輸出了,(當然不是所有的輸入輸出,這個留給以后慢慢學習好了,)那么現在你已經可以在杭電上A題了,(為自己鼓掌,哈哈),接下來大家可以從簡單題下手,本人建議可以先做11頁的題。
當然不會的題歡迎到群內討論,QQ群: <主要面向剛剛入門的13級新生!>
最后還有一個小小的建議:學習貴在堅持!剛剛開始都是比較難的,所以大家要相互鼓勵相互監督,共同進步!
謝謝你的瀏覽!o(∩_∩)o