A+B for Input-Output Practice (I)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13098 Accepted Submission(s): 6187
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
1 5
10 20
Sample Output
6
30
#include<stdio.h>
int main(){
int a, b;
while(~scanf("%d%d", &a, &b))
printf("%d\n", a + b);
return 0;
}
A+B for Input-Output Practice (II)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7593 Accepted Submission(s): 5398
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
2
1 5
10 20
Sample Output
6
30
#include<stdio.h>
int main(){
int a, b, t;
scanf("%d", &t);
while(t--){
scanf("%d%d",&a, &b);
printf("%d\n", a + b);
}
return 0;
}
A+B for Input-Output Practice (III)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8870 Accepted Submission(s): 5142
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
1 5
10 20
0 0
Sample Output
6
30
#include<stdio.h>
int main(){
int a, b, t;
while(~scanf("%d%d", &a, &b) && a || b)
printf("%d\n", a + b);
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): 7942 Accepted Submission(s): 4814
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
4 1 2 3 4
5 1 2 3 4 5
0
Sample Output
10
15
#include<stdio.h>
int main(){
int t, num, sum;
while(~scanf("%d", &t) && t){
sum = 0;
while(t--){
scanf("%d", &num);
sum += num;
}
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): 6184 Accepted Submission(s): 4653
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
2
4 1 2 3 4
5 1 2 3 4 5
Sample Output
10
15
#include<stdio.h>
int main(){
int n, t, num, sum;
scanf("%d", &t);
while(t--){
sum = 0;
scanf("%d", &n);
while(n--){
scanf("%d", &num);
sum += num;
}
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): 6284 Accepted Submission(s): 4538
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
4 1 2 3 4
5 1 2 3 4 5
Sample Output
10
15
#include<stdio.h>
int main(){
int n, num, sum;
while(~scanf("%d", &n)){
sum = 0;
while(n--){
scanf("%d", &num);
sum += num;
}
printf("%d\n", sum);
}
return 0;
}
A+B for Input-Output Practice (VII)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6634 Accepted Submission(s): 4496
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
1 5
10 20
Sample Output
6
30
#include<stdio.h>
int main(){
int a, b;
while(~scanf("%d%d", &a, &b))
printf("%d\n\n", a + b);
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): 13966 Accepted Submission(s): 4508
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
#include<stdio.h>
int main(){
int t, n, num, sum;
scanf("%d", &t);
while(t--){
sum = 0;
scanf("%d", &n);
while(n--){
scanf("%d", &num);
sum += num;
}
printf("%d\n", sum);
if(t > 0){
printf("\n");
}
}
return 0;
}
唯一需要说明的是最后一次输出不应有空行。
=======================签 名 档=======================
原文地址(我的博客):http://www.clanfei.com/2012/07/1543.html
欢迎访问交流,至于我为什么要多弄一个博客,因为我热爱前端,热爱网页,我更希望有一个更加自由、真正属于我自己的小站,或许并不是那么有名气,但至少能够让我为了它而加倍努力。。
=======================签 名 档=======================
分享到:
相关推荐
杭电hdu acm资料所用杭电的acm题
HDU_ACM培训课件(完整版) HDU_ACM培训课件(完整版) HDU_ACM培训课件(完整版) HDU_ACM培训课件(完整版)
杭电 hdu acm 第1084题的解法,ac过了,是一位学长教我的.内有一些中文说明.
HDU_ACM_1002_大数相加C源代码,利用字符串处理
此程序为hdu的acm2010题,就是解决水仙花数问题
杭电acm解题报告 详细解析2000-2099 适合acm初学者
杭州电子科技大学ACM Steps中Chapter One-Section One的答案集。不要直接抄哦~~ 如需题解请上我的博客~ 博客地址呈上:http://blog.csdn.net/xu_zh
杭州电子科技大学ACM Steps中Chapter One-Section Two的答案集。不要直接抄哦~~ 如需题解请上我的博客~ 博客地址呈上:http://blog.csdn.net/xu_zh
题目链接题目意思有n个城镇,编号为0~n-1,m条道路,从一个城镇到另一个城镇有多条路,现在问你从一个城镇到另一个城镇的最短距离是多少。其中要注意的是,城镇之间
题目链接题目意思给你n个点,让你在这n个点之间加边,但是不管咋加都不能形成三个点的直接相通环,让求最大的边数。要求最大的边数还不能出现三个边的环,我们可以将n个
For a positive integer n, let’s denote function f(n,m) as the m-th smallest integer x that x>n and gcd(x,n)=1. For example, f(5,1)=6 and f(5,5)=11. You are given the value of m and (f(n,m)?...
ACM比赛解题报告,包括hdu1880、zoj1010、zoj1015,为原创的报告,算法不一定最优的
hdu_2102_passed_sorce
acm经典题、结题报告,对初学者非常用用,我就从中学到了很多东西
杭电oj4405,一道简单的概率dp题目
写一个数据结构算法,杭电上一道题目,有关数据结构的题目。
模式识别_hdu_期末复习资料集合_试卷笔记.zip
杭电的一些acm题目,都是我自己一个一个自己提交的
数字图像处理_hdu_期末复习资料_试卷等.zip
数字图像处理总ppt_hdu_许老师.pdf