闲来无事,做了杭电里A+B题目:
1000:
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
1 1
Sample Output
2
#include <iostream> using namespace std; int main() { int A,B,sum; while(cin>>A>>B) { sum=0; sum=A+B; cout<<sum<<endl; } return 0; }
1002:
Problem Description
I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.
Input
The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of 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. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.
Sample Input
2 1 2 112233445566778899 998877665544332211
Sample Output
Case 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110
//很遗憾,没写出来,以后补充吧
1089:
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
1 5 10 20
Sample Output
6 30
#include <iostream> using namespace std; int main() { int A,B,sum; while(cin>>A>>B) { sum=0; sum=A+B; cout<<sum<<endl; } return 0; }
1090:
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
2 1 5 10 20
Sample Output
6 30
#include <iostream> using namespace std; int main() { int n; int a,b,sum; cin>>n; while(n--) { sum=0; cin>>a>>b; sum=a+b; cout<<sum<<endl; } return 0; }
1091:
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
1 5 10 20 0 0
Sample Output
6 30
#include <iostream> using namespace std; int main() { int A,B,sum; while(cin>>A>>B) { if(A==0&&B==0) { break; } else { sum=0; sum=A+B; cout<<sum<<endl; } } return 0; }
1092:
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
4 1 2 3 4 5 1 2 3 4 5 0
Sample Output
10 15
#include <iostream> using namespace std; int main() { int n; int sum; while(cin>>n) { if(n==0) { break; } else { int arr[100]; sum=0; for(int i=0;i<n;i++) cin>>arr[i]; for(int i=0;i<n;i++) { sum+=arr[i]; } cout<<sum<<endl; } } return 0; }
1093:
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
2 4 1 2 3 4 5 1 2 3 4 5
Sample Output
10 15
#include <iostream> using namespace std; int main() { int n; cin>>n; int sum,num; while(n--) { sum=0; int i; cin>>i; for(int j=1;j<=i;j++) { cin>>num; sum+=num; } cout<<sum<<endl; } return 0; }
1094:
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
4 1 2 3 4 5 1 2 3 4 5
Sample Output
10 15
#include <iostream> using namespace std; int main() { int sum,num,i; while(cin>>num) { sum=0; int s; for(int j=1;j<=num;j++) { cin>>s; sum+=s; } cout<<sum<<endl; } return 0; }
1095:
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
1 5 10 20
Sample Output
6 30
#include <iostream> using namespace std; int main() { int A,B,sum; while(cin>>A>>B) { sum=A+B; cout<<sum<<endl; cout<<endl; } return 0; }
1096:
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
#include <iostream> using namespace std; int main() { int n; int sum; cin>>n; while(n--) { sum=0; int m; cin>>m; int num; while(m--) { cin>>num; sum+=num; } cout<<sum<<endl; if(n!=0) cout<<endl; } return 0; }
1228:
Problem Description
读入两个小于100的正整数A和B,计算A+B.
需要注意的是:A和B的每一位数字由对应的英文单词给出.
Input
测试输入包含若干测试用例,每个测试用例占一行,格式为"A + B =",相邻两字符串有一个空格间隔.当A和B同时为0时输入结束,相应的结果不要输出.
Output
对每个测试用例输出1行,即A+B的值.
Sample Input
one + two = three four + five six = zero seven + eight nine = zero + zero =
Sample Output
3 90 96
//现在不会
1229:
Problem Description
读入两个小于10000的正整数A和B,计算A+B。需要注意的是:如果A和B的末尾K(不超过8)位数字相同,请直接输出-1。
Input
测试输入包含若干测试用例,每个测试用例占一行,格式为"A B K",相邻两数字有一个空格间隔。当A和B同时为0时输入结束,相应的结果不要输出。
Output
对每个测试用例输出1行,即A+B的值或者是-1。
Sample Input
1 2 1 11 21 1 108 8 2 36 64 3 0 0 1
Sample Output
3 -1 -1 100
//现在不会
1230:
Problem Description
读入两个不超过25位的火星正整数A和B,计算A+B。需要注意的是:在火星上,整数不是单一进制的,第n位的进制就是第n个素数。例如:地球上的10进制数2,在火星上记为“1,0”,因为火星个位数是2进制的;地球上的10进制数38,在火星上记为“1,1,1,0”,因为火星个位数是2进制的,十位数是3进制的,百位数是5进制的,千位数是7进制的……
Input
测试输入包含若干测试用例,每个测试用例占一行,包含两个火星正整数A和B,火星整数的相邻两位数用逗号分隔,A和B之间有一个空格间隔。当A或B为0时输入结束,相应的结果不要输出。
Output
对每个测试用例输出1行,即火星表示法的A+B的值。
Sample Input
1,0 2,1 4,2,0 1,2,0 1 10,6,4,2,1 0 0
Sample Output
1,0,1 1,1,1,0 1,0,0,0,0,0
//现在不会
1412:
Problem Description
读入两个不超过25位的火星正整数A和B,计算A+B。需要注意的是:在火星上,整数不是单一进制的,第n位的进制就是第n个素数。例如:地球上的10进制数2,在火星上记为“1,0”,因为火星个位数是2进制的;地球上的10进制数38,在火星上记为“1,1,1,0”,因为火星个位数是2进制的,十位数是3进制的,百位数是5进制的,千位数是7进制的……
Input
测试输入包含若干测试用例,每个测试用例占一行,包含两个火星正整数A和B,火星整数的相邻两位数用逗号分隔,A和B之间有一个空格间隔。当A或B为0时输入结束,相应的结果不要输出。
Output
对每个测试用例输出1行,即火星表示法的A+B的值。
Sample Input
1,0 2,1 4,2,0 1,2,0 1 10,6,4,2,1 0 0
Sample Output
1,0,1 1,1,1,0 1,0,0,0,0,0
//现在不会
1720:
Problem Description
Many classmates said to me that A+B is must needs.
If you can’t AC this problem, you would invite me for night meal. ^_^
Input
Input may contain multiple test cases. Each case contains A and B in one line.
A, B are hexadecimal number.
Input terminates by EOF.
Output
Output A+B in decimal number in one line.
Sample Input
1 9 A B a b
Sample Output
10 21 21
//现在不会
1753:
Problem Description
话说,经过了漫长的一个多月,小明已经成长了许多,所以他改了一个名字叫“大明”。
这时他已经不是那个只会做100以内加法的那个“小明”了,现在他甚至会任意长度的正小数的加法。
现在,给你两个正的小数A和B,你的任务是代表大明计算出A+B的值。
Input
本题目包含多组测试数据,请处理到文件结束。
每一组测试数据在一行里面包含两个长度不大于400的正小数A和B。
Output
请在一行里面输出输出A+B的值,请输出最简形式。详细要求请见Sample Output。
Sample Input
1.1 2.9 1.1111111111 2.3444323343 1 1.1
Sample Output
4 3.4555434454 2.1
//待续
1866:
Problem Description
As always, A + B is the necessary problem of this warming-up contest. But the patterns and contents are different from the previous ones. Now I come up with a new “A + B” problem for you, the top coders of HDU.
As we say, the addition defined between two rectangles is the sum of their area . And you just have to tell me the ultimate area if there are a few rectangles.
Isn’t it a piece of cake for you? Come on! Capture the bright “accepted” for yourself.
Input
There come a lot of cases. In each case, there is only a string in one line. There are four integers, such as “(x1,y1,x2,y2)”, describing the coordinates of the rectangle, with two brackets distinguishing other rectangle(s) from the string. There lies a plus symbol between every two rectangles. Blanks separating the integers and the interpunctions are added into the strings arbitrarily. The length of the string doesn’t exceed 500.
0<=x1,x2<=1000,0<=y1,y2<=1000.
Output
For each case, you just need to print the area for this “A+B” problem. The results will not exceed the limit of the 32-signed integer.
Sample Input
(1,1,2,2)+(3,3,4,4) (1,1,3,3)+(2,2,4,4)+(5,5,6,6)
Sample Output
2 8
待续.....
1867:
Problem Description
Generally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two strings, such as “asdf” and “sdfg”, the result of the addition between them is “asdfg”, for “sdf” is the tail substring of “asdf” and the head substring of the “sdfg” . However, the result comes as “asdfghjk”, when you have to add “asdf” and “ghjk” and guarantee the shortest string first, then the minimum lexicographic second, the same rules for other additions.
Input
For each case, there are two strings (the chars selected just form ‘a’ to ‘z’) for you, and each length of theirs won’t exceed 10^5 and won’t be empty.
Output
Print the ultimate string by the book.
Sample Input
asdf sdfg asdf ghjk
Sample Output
asdfg asdfghjk
待续.....
2033:
Problem Description
HDOJ上面已经有10来道A+B的题目了,相信这些题目曾经是大家的最爱,希望今天的这个A+B能给大家带来好运,也希望这个题目能唤起大家对ACM曾经的热爱。
这个题目的A和B不是简单的整数,而是两个时间,A和B 都是由3个整数组成,分别表示时分秒,比如,假设A为34 45 56,就表示A所表示的时间是34小时 45分钟 56秒。
Input
输入数据有多行组成,首先是一个整数N,表示测试实例的个数,然后是N行数据,每行有6个整数AH,AM,AS,BH,BM,BS,分别表示时间A和B所对应的时分秒。题目保证所有的数据合法。
Output
对于每个测试实例,输出A+B,每个输出结果也是由时分秒3部分组成,同时也要满足时间的规则(即:分和秒的取值范围在0~59),每个输出占一行,并且所有的部分都可以用32位整数表示。
Sample Input
2 1 2 3 4 5 6 34 45 56 12 23 34
Sample Output
5 7 9 47 9 30
考虑好进位即可
#include <iostream> using namespace std; int main() { int n; cin>>n; while(n--) { int ah,am,as,bh,bm,bs; cin>>ah>>am>>as>>bh>>bm>>bs; int sum_h,sum_m,sum_s; int jin_h=0;int jin_m=0; sum_s=as+bs; if(sum_s>=60) { sum_s-=60; jin_m++; } sum_m=am+bm+jin_m; if(sum_m>=60) { sum_m-=60; jin_h++; } sum_h=ah+bh+jin_h; cout<<sum_h<<" "<<sum_m<<" "<<sum_s<<endl; } return 0; }
待续.....
2055:
Problem Description
we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, ... f(Z) = 26, f(z) = -26;
Give you a letter x and a number y , you should output the result of y+f(x).
Input
On the first line, contains a number T.then T lines follow, each line is a case.each case contains a letter and a number.
Output
for each case, you should the result of y+f(x) on a line.
Sample Input
6 R 1 P 2 G 3 r 1 p 2 g 3
Sample Output
19 18 10 -17 -14 -4
字符不熟,方法略显麻烦,待日后完善
#include <iostream> using namespace std; int f(char letter) { int num; if(letter>=65&&letter<=90) { num=int(letter)-64; } else { num=-(int(letter)-96); } return num; } int main() { int t; cin>>t; while(t--) { char x; int y; cin>>x>>y; cout<<f(x)+y<<endl; } return 0; }
2057:
Problem Description
There must be many A + B problems in our HDOJ , now a new one is coming.
Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too.
Easy ? AC it !
Input
The input contains several test cases, please process to the end of the file.
Each case consists of two hexadecimal integers A and B in a line seperated by a blank.
The length of A and B is less than 15.
Output
For each test case,print the sum of A and B in hexadecimal in one line.
Sample Input
+A -A +1A 12 1A -9 -1A -12 1A -AA
Sample Output
0 2C 11 -2C -90
待续.....
2096:
Problem Description
小明今年3岁了, 现在他已经能够认识100以内的非负整数, 并且能够进行100以内的非负整数的加法计算.
对于大于等于100的整数, 小明仅保留该数的最后两位进行计算, 如果计算结果大于等于100, 那么小明也仅保留计算结果的最后两位.
例如, 对于小明来说:
1) 1234和34是相等的
2) 35+80=15
给定非负整数A和B, 你的任务是代表小明计算出A+B的值.
Input
输入数据的第一行为一个正整数T, 表示测试数据的组数. 然后是T组测试数据. 每组测试数据包含两个非负整数A和B(A和B均在int型可表示的范围内).
Output
对于每组测试数据, 输出小明A+B的结果.
Sample Input
2 35 80 15 1152
Sample Output
15 67
待续.....
未完待续.....