桃花潭水深千尺,不及AC送我情~
A+B for Input-Output Practice (VIII)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 40850 Accepted Submission(s): 12244
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 void main() { int n,i,j,t,sum,a,out[1000],q; sum=0; scanf(“%dn”,&n); for (i=0;i<n;i++) { scanf(“%d”,&j); for (t=0;t<j;t++) { scanf(“%d”,&a); sum=sum+a; out[i]=sum; } sum=0; } q=n-1; for (i=0;i<q;i++) { printf(“%dnn”,out[i]); } printf(“%dn”,out[q]); }
唔,写的比较麻烦。一开始试提示有格式错误.检查了一下,发现是最后面多了一行空行,RT。
#include int main() { int a,b,i,j,l[1000],k; scanf(“%d”,&i); getchar(); for(j=1;j<=i;j++) l[j]=0; for(j=1;j<=i;j++) { scanf(“%d”,&a); getchar(); for(k=1;k<=a;k++) { scanf(“%d”,&b); getchar(); l[j]+=b; } } for(j=1;j<=i-1;j++) printf(“%dnn”,l[j]); printf(“%dn”,l[i]); }
至此,ACM steps1 系列的题目全部AC~撒花~