//主要是训练输入输出的格式,以下八道题仅供参考。
A+B for Input-Output Practice (I)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 97643 Accepted Submission(s): 54096
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.
1 5 10 20
6 30
int main(){
int a,b,c;
while(scanf("%d%d",&a,&b)!=EOF)
{ c=a+b;
printf("%d\n",c);
}
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): 73531 Accepted Submission(s): 47796
2 1 5 10 20
6 30
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
while(n--)
{ int a,b;
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): 84436 Accepted Submission(s): 44289
1 5 10 20 0 0
6 30
#include<stdio.h>
int main(){
int a,b;
while(scanf("%d%d",&a,&b)&&(a!=0|b!=0))
{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): 76413 Accepted Submission(s): 40901
4 1 2 3 4 5 1 2 3 4 5 0
10 15
#include<stdio.h>
int main(){
int n,i, a[200],sum;
while(scanf("%d",&n)&&n!=0)
{ sum=0;
for( i=0;i<n;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): 56776 Accepted Submission(s): 38249
2 4 1 2 3 4 5 1 2 3 4 5
10 15
#include<stdio.h>
int main(){
int n,a[300],i;
scanf("%d",&n);
while(n--)
{ int s,sum=0;
scanf("%d",&s);
for(i=0;i<s;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): 53108 Accepted Submission(s): 35824
4 1 2 3 4 5 1 2 3 4 5
10 15
#include<stdio.h>
int main(){
int n,a[500] ;
while(scanf("%d",&n)!=EOF)
{ int i,sum=0;
for(int i=0;i<n;i++)
{scanf("%d",&a[i]);
sum=sum+a[i];
}
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): 52590 Accepted Submission(s): 35249
1 5 10 20
6 30
#include<stdio.h>
int main(){
int a,b,i=0,k,c;
while(scanf("%d%d",&a,&b)!=EOF)
{ c=a+b;
printf("%d\n\n",c);
}
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): 114481 Accepted Submission(s): 35137
3 4 1 2 3 4 5 1 2 3 4 5 3 1 2 3
10 15 6
#include<stdio.h>
int main(){
int n ,a[100];
scanf("%d",&n);
while(n--)
{ int s,sum=0;
scanf("%d",&s);
for(int i=0;i<s;i++)
{scanf("%d",&a[i]);
sum=sum+a[i];
}
if(n)
printf("%d\n\n",sum);
else printf("%d\n",sum);
}
return 0;
}