1、#include void main() int a,b; while(scanf(%d %d,&a,&b)!=EOF) printf(%dn,a+b); Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + . + n.The input will consist of a series of integers n, one integer per line.For each case, outp
2、ut 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.11005050 int n,sum,i;%dn)! sum=0; for( i=0;i=n;i+) sum+=i;%dnn,sum);I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.The
3、 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 o
4、f each integer will not exceed 1000.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
5、 two test cases.1 2112233445566778899 998877665544332211Case 1:1 + 2 = 3Case 2:112233445566778899 + 998877665544332211 = 111111*1110#include int main() char str11001, str21001; int t, i, len_str1, len_str2, len_max, num = 1, k; scanf(, &t); getchar(); while(t-) int a1001 = 0, b1001 = 0, c1001 = 0; s
6、canf(%s, str1); len_str1 = strlen(str1); for(i = 0; i len_str2) len_max = len_str1; else len_max = len_str2; k = 0;= len_max - 1; +i) ci = (ai + bi + k) % 10; k = (ai + bi + k) / 10; if(k != 0) clen_max = 1; printf(Case %d:n, num); num+;%s + %s = , str1, str2); if(clen_max = 1) printf(1); for(i = le
7、n_max - 1; i = 0; -i), ci); if(t = 1) return 0;Given a sequence a1,a2,a3.an, your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.=20) which means the number of test cases. Then T lines follow, each line start
8、s with a number N(1=N=0) stri=stri-1+ai; starti=starti-1; else stri=ai; starti=i; max=str1;end=1; for(k=2;kmax) max=strk; end=k;,num);%d %d %dn,max,startend,end); if(t)Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.This year, they decide to leave this lovely job to yo
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1