杭电2000~
A+B for Input-Output Practice (VIII)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5573 Accepted Submission(s): 2058
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
using namespace std;
int main()
{
int m,n,i,j,s,k;
cin>>n;
int c[1000];
for(i=0;i<n;i++)< p="">
{
cin>>m;
s=0;
for(j=1;j<=m;j++)
{
cin>>k;
s+=k;
}
if(i==n-1)
{
cout<<s<<endl;< p="">
}
else
{
cout<<s<<endl<<endl;< p="">
}
}
return 0;
}
A+B Coming
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 902 Accepted Submission(s): 456
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
正确代码:
#include
using namespace std;
int main()
杭州电子科技大学{
int m,n,s;
while(scanf("%x%x",&m,&n)!=EOF) //以十六进制输入
{
s=m+n;
printf("%d\n",s); //以十进制输出,与上面
}
return 0;
}
此题的输入输出没有用cin>> 和cout<<,看到很多人说scanf和printf比较常用2001ASCII码排序
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 32853 Accepted Submission(s): 13545