ACM部分习题答案:
A + B Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 100972 Accepted Submission(s): 33404
Problem Description
Calculate A + B.
Input
Each line will contain two integers A and B. Process to end of file.
Output
For each ca, output A + B in one line.
Sample Input
1 1
Sample Output
2
# include<stdio.h>
Int main()
{int x,y,s;
while(scanf("%d %d",&x,&y)!=EOF)
{s=x+y;
printf("%d\n",s);}
return 0;
}
Sum Problem
Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 85964 Accepted Submission(s): 19422
Problem Description
Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).
In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
Input
学习反思怎么写
The input will consist of a ries of integers n, one integer per line.
Output
For each ca, output 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.
Sample Input
1
100
Sample Output
1
土员
5050
# include<stdio.h>
int main()
{int n;
long int s;
while(scanf("%d",&n)!=EOF)
{ s=0;
while(n>0)
{s=s+n;
n--;
}
printf("%ld\n\n",s);
}
return 0;
}
A + B Problem II
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 58216 Accepted Submission(s): 10500
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 cas. 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 ca, you should output two lines. The first line is "Ca #:", # means the number of the test ca. The cond line is the an equation "A + B = Sum", Sum means t
he result of A + B. Note there are some spaces int the equation. Output a blank line between two test cas.
Sample Input
2
1 2
112233445566778899 998877665544332211
Sample Output
Ca 1:
1 + 2 = 3
Ca 2:
112233445566778899 + 998877665544332211 = 111111*********1110
#include<stdio.h>
#include<string.h>
int main()
{ char x[1001],y[1001],z[1001];
int n,i,j,k,m,o;
scanf("%d",&n);
o=n;
while(n--)
{ scanf("%s%s",x,y);
i=strlen(x); j=strlen(y);
for(k=0,m=0;i>0&&j>0;i--,j--)
{
m+=x[i-1]-'0'+y[j-1]-'0';
z[k++]=m%10+'0'; m/=10;
}
for(;i>0;i--) 唐朝丝绸之路
{
m+=x[i-1]-'0';
z[k++]=m%10+'0';
m/=10;
}
for(;j>0;j--)
{ m+=y[j-1]-'0';
z[k++]=m%10+'0'; m/=10;
}
if(m>0) z[k++]=m%10+'0';
printf("Ca %d:\n%s + %s = ",o-n,x,y);
for(;k>0;k--) printf("%c",z[k-1]);
printf("\n"); if(n) printf("\n"); }
return 0;
}
Let the Balloon Ri
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 24082 Accepted Submission(s): 7343
Problem Description
Contest time again! How excited it is to e balloons floating around. But to tell you a cret, 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 you.
Input
Input contains multiple test cas. Each test ca starts with a number N (0 < N <= 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-ca letters.
A test ca with N = 0 terminates the input and this test ca is not to be procesd.
Output
For each ca, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test ca.
Sample Input
5
面膜的作用和功效green
red
blue
red
red
3
pink
orange
pink
0
Sample Output
red
pink
赵王城遗址公园#include<stdio.h>
#include<string.h>
void main()
{阴道炎有什么症状
int n,i,j,k,t,a[1001];
char h[1001][16];
while(scanf("%d",&n)!=EOF)
{
if(n==0) break;
for(i=0;i<=n;++i) a[i]=0;
t=i=k=0;
while(i<n) scanf("%s",h[i++]);
for(i=0;i<n;++i)
for(j=i+1;j<n;++j)
if(strcmp(h[i],h[j])==0)
{
++a[i];
if(a[i]>k)
{
k=a[i];