杭电acm答案无敌版杭电acm答案无敌版
选修选考选作选
姓名,春杰.........................................................................................................................................1
选,选商14...................................................................................................
杭电acm答案无敌版
选修选考选作选
姓名,春杰.........................................................................................................................................1
选,选商14............................................................................................................................................1
1001 Sum Problem..............................................................................................................................2
1089 A+B for Input-Output Practice (I).............................................................................................4
1090 A+B for Input-Output Practice (II)...........................................................................................6
1091 A+B for Input-Output Practice (III)..........................................................................................8
1092 A+B for Input-Output Practice (IV)...........................................................................................9
1093 A+B for Input-Output Practice (V).........................................................................................11
1094 A+B for Input-Output Practice (VI)........................................................................................13
1095 A+B for Input-Output Practice (VII).......................................................................................15
1096 A+B for Input-Output Practice (VIII).....................................................................................16
选排序2000 ASCII.............................................................................................................................17
选算点选的距两离2001......................................................................................................................19
选算球选体2002....................................................................................................................................20
求选选选2003........................................................................................................................................21
成选选选2004........................................................................................................................................22
第天,几2005..................................................................................................................................24
求奇的乘选数2006............................................................................................................................26
平方和立方和与2007......................................................................................................................27
数选选选2008..........................................................................................................................................28
求列的和数2009..............................................................................................................................30
水仙花数2010..................................................................................................................................31
多选式求和2011................................................................................................................................33
素判定数2012..................................................................................................................................34
青年歌手大选选选委打分会2014_......................................................................................................36
偶求和数2015..................................................................................................................................37
数据的交选选出2016..........................................................................................................................40
字符串选选2017..................................................................................................................................41
数列有序2019!.................................................................................................................................43
选选选排序 2020..................................................................................................................................44
选工选,,咯2021..............................................................................................................................46
人选人选2033A+B..............................................................................................................................48
三角形2039......................................................................................................................................49
选和数2040........................................................................................................................................51
姓名,春杰
选,选商14
1001 Sum Problem
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 series of integers n, one integer per line.
Output
For each case, 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
Author
DOOM III
解答,
#include
main()
{
int n,i,sum;
sum=0;
while((scanf("%d",&n)!=-1))
{
sum=0;
for(i=0;i<=n;i++)
sum+=i;
printf("%d\n\n",sum);
}
}
1089 A+B for Input-Output Practice (I)Problem Description
Your task is to Calculate a + b.
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.
Input
The input will consist of a series of pairs of integers a and b, separated by a space, one pair of
integers per line.
Output
For each pair of input integers a and b you should output the sum of a and b in one line, and with
one line of output for each line in input.
Sample Input
1 5
10 20
Sample Output
6
30
Author
lcy
Recommend
JGShining
解答,
#include
main()
{
int a,b; while(scanf("%d%d",&a,&b)!=EOF) printf("%d\n",a+b); }
1090 A+B for Input-Output Practice (II)Problem Description
Your task is to Calculate a + b.
Input
Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair of
integers a and b, separated by a space, one pair of integers per line.
Output
For each pair of input integers a and b you should output the sum of a and b in one line, and with
one line of output for each line in input.
Sample Input
2
1 5
10 20
Sample Output
6
30
Author
lcy
Recommend
JGShining
解答,
#include
#define M 1000
void main(){
int a ,b,n,j[M],i;
//printf("please input n:\n");
scanf("%d",&n);
for(i=0;i
main()
{
int a,b;
scanf("%d %d",&a,&b);
while(!(a==0&&b==0))
{
printf("%d\n",a+b);
scanf("%d %d",&a,&b);
}
}
1092A+B for Input-Output Practice (IV)Problem Description
Your task is to Calculate the sum of some integers.
Input
Input contains multiple test cases. Each test case contains a integer N, and then N integers follow
in the same line. A test case starting with 0 terminates the input and this test case is not to be
processed.
Output
For each group of input integers you should output their sum in one line, and with one line of
output for each line in input.
Sample Input
4 1 2 3 4
5 1 2 3 4 5
0
Sample Output
10
15
Author
lcy
RecommendJGShining
解答,
#include
int main()
{
int n,sum,i,t;
while(scanf("%d",&n)!=EOF&&n!=0)
{
sum=0;
for(i=0;i
main()
{
int n,a,b,i,j,sum;
sum=0;
while(scanf("%d\n",&n)!=-1)
{
for(i=0;imain()
{
int n,a,b,i,j,sum;
sum=0;
while(scanf("%d\n",&n)!=-1)
{
for(j=0;j
main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
printf("%d\n\n",a+b);
}
1096 A+B for Input-Output Practice (VIII)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
Author
lcy
RecommendJGShining
解答,
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("%d\n\n",l[j]);
printf("%d\n",l[i]);
}
选排序2000 ASCII
Problem Description
选入三字符后~按各字符的个选小到大的选序选出选三字符。从个ASCII
Input
选入据有多选~每选占一行~有三字符选成~之选无空格。数个
Output
选于每选选入据~选出一行~字符中选用一空格分选。数个
Sample Input
qwe
asd
zxc
Sample Output
e q w
a d s
c x z
Authorlcy
Source选言程序选选选选;一, C
Recommend
JGShining解答,
#include
main()
{
char a,b,c,d;
while(scanf("%c %c %c",&a,&b,&c)!=EOF)
{
getchar();
if(a>=b)
{
if(c>=a)
printf("%c %c %c\n",b,a,c);
else if(b>=c)
printf("%c %c %c\n",c,b,a);
else if(b=b)
printf("%c %c %c\n",a,b,c);
else if(c>=a)
printf("%c %c %c\n",a,c,b);
else if(a>c)
printf("%c %c %c\n",c,a,b);
}
}
}
选算点选的距两离2001Problem Description
选入点坐选;两,;,选算选出点选的距。并两离X1,Y1,X2,Y2,
Input
选入据有多选~每选占一行~由数个数选选选成~分选示数据之选用空格隔选。4x1,y1,x2,y2,
Output
选于每选选入据~选出一行~选果保留位小。数两数
Sample Input0 0 0 1
0 1 1 0
Sample Output1.00
1.41
Author
lcy
Source
选言程序选选选选;一, C
Recommend
JGShining
解答,
#include#includemain()
{
double a,b,c,d,s;
while(scanf("%lf %lf %lf %lf",&a,&b,&c,&d)!=EOF)
{
s=sqrt((a-c)*(a-c)+(b-d)*(b-d));
printf("%.2lf\n",s);
}
}
选算球选体2002
Problem Description
根据选入的半选~选算球的选。径体
Input
选入据有多选~每选占一行~每行包括一选~表示球的半选。数个数径
Output
选出选选的球的选~选于每选选入据~选出一行~选算选果保留三位小。体数数
Sample Input1
1.5
Sample Output4.189
14.137
Hint
#define PI 3.1415927
Author
lcy
Source
选言程序选选选选;一, C
Recommend
JGShining
解答,
#include#define PI 3.1415927main()
{
double a,v;
while(scanf("%lf",&a)!=EOF)
{
v=4*PI*a*a*a/3;
printf("%.3lf\n",v);
}
}
求选选选2003Problem Description
求选的选选选。数
Input
选入据有多选~每选占一行~每行包含一选选。数个数
Output
选于每选选入据~选出的选选选~要求每选据选出一行~选果保留位小。数它数两数
Sample Input123
-234.00
Sample Output
123.00
234.00
Author
lcy
Source
选言程序选选选选;一, C
RecommendJGShining
解答,
#include
main()
{
double a;
while(scanf("%lf",&a)!=EOF)
{
if(a<0)
a=-a;
printf("%.2lf\n",a);
}
}
成选选选2004
Problem Description
选入一百分制的成选个~其选选成选选的等选~具选选选选如下,将体t
选90~100A;
选80~89B;
选70~79C;
选60~69D;
选0~59E;
Input
选入据有多选~每选占一行~由一整选成。数个数
Output
选于每选选入据~选出一行。如果选入据不在数数范选~选选出一行,“内。0~100Score is error!”
Sample Input56
67
100
123
Sample Output
E
D
A
Score is error!
Author
lcy
Source
选言程序选选选选;一, C
RecommendJGShining
解答,
#include
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n>100||n<0)printf("Score is error!\n");
else if(n>=90)printf("A\n");
else if(n>=80)printf("B\n");
else if(n>=70)printf("C\n");
else if(n>=60)printf("D\n");
else printf("E\n");
}
return 0;
}
第天,几2005
Problem Description
选定一日期~选出选日期是选年的第天。个个几
Input
选入据有多选~每选占一行~据格式选数数选成~具选体参另外~YYYY/MM/DDsample input ,
可以向保所有的选入据是合法的。你确数
Output
选于每选选入据~选出一行~表示选日期是选年的第天。数几
Sample Input1985/1/20
2006/3/12
Sample Output20
71
Author
lcy
Source
选言程序选选选选;一, C
Recommend
JGShining
解答,
#include
main()
{
int a,b,c,d,e,f,g;
while(scanf("%d/%d/%d",&a,&b,&c)!=EOF)
{
if(b==1)
d=c;
else if(b==2)
d=31+c;
else if(b==3)
d=31+28+c;
else if(b==4)
d=31+28+31+c;
else if(b==5)
d=31+31+28+30+c;
else if(b==6)
d=31+28+31+30+31+c;
else if(b==7)
d=31+28+31+30+31+30+c;
else if(b==8)
d=31+28+31+30+31+30+31+c;
else if(b==9)
d=31+28+31+30+31+30+31+31+c;
else if(b==10)
d=31+28+31+30+31+30+31+31+30+c;
else if(b==11)
d=31+28+31+30+31+30+31+31+30+31+c;
else if(b==12)
d=31+28+31+30+31+30+31+31+30+31+c+30;
e=a%100;
f=a%400;
g=a%4;
if(e==0)
{
if(f==0)
d=1+d;
else
d=d;
}
else if(g=0)
d=d+1;
else
d=d;
printf("%d\n",d);
}
}
求奇的乘选数2006
Problem Description
选你个数数整~求他选中所有奇的乘选。n
Input
选入据包含多选选选例~每选选选例占一行~每行的第一选数个个个数~表示本选据一共有数个~nn
接着是个数你数个数整~可以假选每选据必定至少存在一奇。n
Output
选出每选中的所有奇的乘选~选于选选选例~选出一行。数数
Sample Input3 1 2 3
4 2 3 4 5
Sample Output3
15
Author
lcy
Source
选言程序选选选选;一, C
Recommend
JGShining
解答,
#include
main()
{
int n,s,i,a;
while(scanf("%d",&n)!=EOF)
{
s=1;
for(i=0;i
int main()
{
int sum1,sum2,n,i,m,t;
while(scanf("%d%d",&m,&n)!=EOF)
{
sum1=sum2=0;
if(m>n){t=m;m=n;n=t;}
for(i=m;i<=n;i++)
{
if(i%2==0) sum1+=(i*i);
else sum2+=(i*i*i);
}
printf("%d %d\n",sum1,sum2);
}
return 0;
}
数选选选2008
Problem Description
选选选定的个数数数个数中~选、零和正的。n
Input
选入据有多选~每选占一行~每行的第一是整数个数数;,~表示需要选选的选的数个数~nn<100
然后是个数选选~如果~选表示选入选束~选行不做选理。nn=0
Output
选于每选选入据~选出一行数和~分选表示选定的据中选、零和正的。数数数个数a,bc
Sample Input6 0 1 2 3 -1 05 1 2 3 4 0.50
Sample Output1 2 3
0 0 5
Author
lcy
Source
选言程序选选选选;二, C
RecommendJGShining
解答,
#include
int main()
{
int n,i,b1,b2,b3;
double a[101];
while(scanf("%d",&n)!=EOF && n!=0)
{
for(i=0;i#includemain()
{
double n,m,s,w,i;
while(scanf("%lf%lf",&n,&m)!=EOF)
{
s=n;
for(i=1;i
main()
{
int m,n,i,w,a,b,c,j,s,d;
while(scanf("%d %d",&n,&m)!=EOF)
{
d=0;
j=1;
if(m>n)
{
w=m;
m=n;
n=w;
}
else ;
for(i=m;i<=n;i++)
{
a=i/100;
b=i/10%10;
c=i%10;
s=a*a*a+b*b*b+c*c*c;
if(i==s)
{
if(d!=0)
printf(" ");
printf("%d",i);
d=d+1;
j=j+1;
}
}
if(j==1)
printf("no\n");
else
printf("\n");
}
}
多选式求和2011Problem Description多选式的描述如下,
1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6 + ...
选在选求出选多选式的前你选的和。n
Input
选入据由数行选成~首先是一正整个数;,~表示选选选例的~第二行包含个数个2mm<100m
正整~选于每一整数个数不妨选选,~求选多选式的前选的和。(n,n<1000n
Output
选于每选选选例个~要求选出多选式前选的和。每选选选例的选出占一行~选果保留个位小。数nn2
Sample Input
2
1 2
Sample Output
1.00
0.50
Author
lcy
Source
选言程序选选选选;二, C
Recommend
JGShining
解答,
#include#includemain()
{
double m,n,i,s,j,k,a;
while(scanf("%lf",&m)!=EOF)
{
for(i=0;imain()
{
int x,y,i,j,s,k,w,d;
while(scanf("%d%d",&x,&y)==2&&(x!=0||y!=0))
{
w=0;
for(i=x;i<=y;i++)
{
k=i*i+i+41;
for(j=2;j
int main()
{
int n,s,a[100],i,k,b;
double w;
while(scanf("%d",&n)!=EOF)
{
k=0;
w=0;
s=0;
for(i=0;is)
s=a[i];
}
for(i=1;ia[i])
b=a[i];
}
w=(w-s-b)/(k-2);
printf("%.2lf\n",w);
}
}
偶求和数2015
Problem Description
有一选度选个的列~选列定选选数数从选始的选增有序偶~选在要求按照选序每数你n(n<=100)2m
个数个求出一平均选~如果最后不足个数~选以选选量求平均选。选程选出选平均选序列。m
Input
选入据有多选~每选占一行~包含正整数两个数和~和的含选如上所述。nmnm
Output
选于每选选入据~选出一平均选序列~每选选出占一行。数个
Sample Input
3 2
4 2
Sample Output
3 6
3 7
Author
lcy
Source
选言程序选选选选;三, C
Recommendlcy
解答,
#include
main()
{
int n,m,a,b,i,j,k,w,l,e,s,d,r;
while(scanf("%d%d",&n,&m)!=EOF)
{
s=0;
e=0;
l=0;
if(n<=m)
{
for(i=0;i
main()
{
int n,a[100],i,j,k,s,w;
while(scanf("%d",&n)!=EOF&&n!=0)
{
j=0;
for(i=0;ia[i])
{
k=a[i];
j=i;
}
}
w=a[0];
a[0]=k;
a[j]=w;
for(i=0;imain()
{
int n,i,j,a;
char s[1000];
while(scanf("%d",&n)!=EOF)
{
getchar();
for(i=0;i='0'))
a=a+1;
}
printf("%d\n",a);
}
}
}
数列有序2019!
Problem Description
有个数从另个数整~已选按照小到大选序排列好~选在外选一整~选选选选入到序将数插n(n<=100)x
列中~使新的序列仍然有序。并
Input
选入据包含多选选选例~每选据由行选成~第一行是数个数两和~第二行是已选有序的个数nmn
的列。数和同选选选示选入据的选束~本行不做选理。数nm0
Output
选于每选选选例~选出入新的元素后的列。个插数
Sample Input
3 3
1 2 4
0 0
Sample Output1 2 3 4
Author
lcy
Source
选言程序选选选选;三, C
Recommend
lcy
解答,
#includemain()
{
int n,m,a[100],b[100],i,j,k,s,w,d;
scanf("%d%d",&n,&m);
while(!(n==0&&m==0))
{
w=0;
for(i=0;ia[j])
w=w+1;
}
for(j=0;j
main()
{
int n,m,a[100],b[100],c,d,e,f,i,j,k;
while(scanf("%d",&n)!=EOF&&n!=0)
{
for(i=0;i
main()
{
int n,m,a,b,c,d,e,f,i,j,k;
while(scanf("%d",&n)!=EOF&&n!=0)
{
k=0;
for(i=0;i
main()
{int i,j,a,b,c,d,e,f,n,s;while(scanf("%d",&n)!=EOF){ c=0;d=0;e=0;
for(i=0;i60)
{
c=c-60;
j=j+1;
}
b=b+j;
s=0;
while(b>60)
{
b=b-60;
s=s+1;
}
a=a+s;
printf("%d %d %d\n",a,b,c);
}
}
}
三角形2039
Problem Description
选定三选~选判一下能不能选成一三角形。条你断个
Input
选入据第一行包含一数个数~接下有行~每行一选例~包含三正个个数。其中MMA,B,C
A,B,C <1000;
Output
选于每选选选例~如果三选选个条能选成三角形的选~选出~否选。 A,B,CYESNO
Sample Input2
1 2 3
2 2 2
Sample Output
NO
YES
Author
linle
Source
选选班短期考选 学2005
Recommendlcy
解答,
#include
main()
{
double n,a,b,c,i;
while(scanf("%lf",&n)!=EOF)
{
for(i=0;ic&&(b+c)>a&&(a+c)>b)
printf("YES\n");
else
printf("NO\n");
}
}
}
选和数2040Problem Description古希家选哥拉斯在自然究中选选~腊数学达数研的所有选选真数即数不是自身的选之和选, 220()
,。 1+2+4+5+10+11+20+22+44+55+110284
而的所有选选选真数、、、、 ~加起恰好选来。人选选选选的感到奇~之选选数很惊并称28412471142220和。一般地选~如果中任何一都是一的选之和~选选就是选和。数两个数个数另个数真数两个数数
你写个断两个数数的任选就选一程序~判选定的是否是选和
Input
选入据第一行包含一数个数~接下有行~每行一选例个包含整两个数~ 其中 MM,A,B0 <=
A,B <= 600000 ;
Output
选于每选选选例~如果个和是选和的选选出数~否选选出。ABYESNO
Sample Input
2
220 284
100 200
Sample Output
YES
NO
Authorlinle
Source
选选班短期考选 学2005
Recommend
lcy
解答,
#include
main()
{
double n,a,b,c,i;
while(scanf("%lf",&n)!=EOF)
{
for(i=0;ic&&(b+c)>a&&(a+c)>b)
printf("YES\n");
else
printf("NO\n");
}
}
}
本文档为【杭电acm答案无敌版】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。