acm.docx
- 文档编号:12868733
- 上传时间:2023-04-22
- 格式:DOCX
- 页数:56
- 大小:32.18KB
acm.docx
《acm.docx》由会员分享,可在线阅读,更多相关《acm.docx(56页珍藏版)》请在冰豆网上搜索。
acm
A+B for Input-Output Practice (I)
TimeLimit:
1000ms,SpecialTimeLimit:
2500ms,MemoryLimit:
32768KB
Totalsubmitusers:
260,Acceptedusers:
224
Problem10361:
Nospecialjudgement
Problemdescription
YourtaskistoCalculatea+b.Tooeasy?
!
Ofcourse!
Ispeciallydesignedtheproblemforacmbeginners.Youmusthavefoundthatsomeproblemshavethesametitleswiththisone,yes,alltheseproblemsweredesignedforthesameaim.
Input
Theinputwillconsistofaseriesofpairsofintegersaandb,separatedbyaspace,onepairofintegersperline.
Output
Foreachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput.
SampleInput
15
1020
SampleOutput
6
30
#include
intmain()
{
inta,b;
while(scanf("%d%d",&a,&b)!
=EOF)
printf("%d\n",a+b);
return0;
}
+B for Input-Output Practice (II)
TimeLimit:
1000ms,SpecialTimeLimit:
2500ms,MemoryLimit:
32768KB
Totalsubmitusers:
224,Acceptedusers:
211
Problem10362:
Nospecialjudgement
Problemdescription
YourtaskistoCalculatea+b.
Input
InputcontainsanintegerNinthefirstline,andthenNlinesfollow.Eachlineconsistsofapairofintegersaandb,separatedbyaspace,onepairofintegersperline.
Output
Foreachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput.
SampleInput
2
15
1020
SampleOutput
6
30
#include
intmain()
{
intn,i,a,b;
scanf("%d",&n);
for(i=0;i { scanf("%d%d",&a,&b); printf("%d\n",a+b); } return0; } A+B for Input-Output Practice (III) TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 200,Acceptedusers: 182 Problem10363: Nospecialjudgement Problemdescription YourtaskistoCalculatea+b. Input Inputcontainsmultipletestcases.Eachtestcasecontainsapairofintegersaandb,onepairofintegersperline.Atestcasecontaining00terminatestheinputandthistestcaseisnottobeprocessed. Output Foreachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput. SampleInput 15 1020 00 SampleOutput 6 30 #include intmain() { inta,b; while(scanf("%d%d",&a,&b)! =EOF&&(a! =0||b! =0)) printf("%d\n",a+b); return0; } A+B for Input-Output Practice (IV) TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 173,Acceptedusers: 158 Problem10364: Nospecialjudgement Problemdescription YourtaskistoCalculatethesumofsomeintegers. Input Inputcontainsmultipletestcases.EachtestcasecontainsaintegerN,andthenNintegersfollowinthesameline.Atestcasestartingwith0terminatestheinputandthistestcaseisnottobeprocessed. Output Foreachgroupofinputintegersyoushouldoutputtheirsuminoneline,andwithonelineofoutputforeachlineininput. SampleInput 41234 512345 0 SampleOutput 10 15 #include intmain() { intn,count,i; inta[100]; while(scanf("%d",&n)! =EOF&&(n! =0)) { count=0; for(i=0;i { scanf("%d",&a[i]); count+=a[i]; } printf("%d\n",count); } return0; } A+B for Input-Output Practice (V) TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 148,Acceptedusers: 139 Problem10365: Nospecialjudgement Problemdescription Yourtaskistocalculatethesumofsomeintegers. Input InputcontainsanintegerNinthefirstline,andthenNlinesfollow.EachlinestartswithaintegerM,andthenMintegersfollowinthesameline. Output Foreachgroupofinputintegersyoushouldoutputtheirsuminoneline,andwithonelineofoutputforeachlineininput. SampleInput 2 41234 512345 SampleOutput 10 15 #include intmain() { intn,m,i,j; intcount,a[100]; scanf("%d",&n); for(i=0;i { count=0; scanf("%d",&m); for(j=0;j { scanf("%d",&a[j]); count+=a[j]; } printf("%d\n",count); } return0; } A+B for Input-Output Practice (VI) TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 134,Acceptedusers: 122 Problem10366: Nospecialjudgement Problemdescription Yourtaskistocalculatethesumofsomeintegers. Input Inputcontainsmultipletestcases,andonecaseoneline.EachcasestartswithanintegerN,andthenNintegersfollowinthesameline. Output ForeachtestcaseyoushouldoutputthesumofNintegersinoneline,andwithonelineofoutputforeachlineininput. SampleInput 41234 512345 SampleOutput 10 15 #include intmain() { intn,i; inta[100],count; while(scanf("%d",&n)! =EOF) { count=0; for(i=0;i { scanf("%d",&a[i]); count+=a[i]; } printf("%d\n",count); } return0; } A+B for Input-Output Practice (VII) TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 117,Acceptedusers: 109 Problem10368: Nospecialjudgement Problemdescription YourtaskistoCalculatea+b. Input Theinputwillconsistofaseriesofpairsofintegersaandb,separatedbyaspace,onepairofintegersperline. Output Foreachpairofinputintegersaandbyoushouldoutputthesumofaandb,andfollowedbyablankline. SampleInput 15 1020 SampleOutput 6 30 #include intmain() { inta,b; while(scanf("%d%d",&a,&b)! =EOF) { printf("%d\n\n",a+b);//只用一个\n也行 } return0; } A+B for Input-Output Practice (VIII) TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 105,Acceptedusers: 100 Problem10369: Nospecialjudgement Problemdescription Yourtaskistocalculatethesumofsomeintegers. Input InputcontainsanintegerNinthefirstline,andthenNlinesfollow.EachlinestartswithaintegerM,andthenMintegersfollowinthesameline. Output Foreachgroupofinputintegersyoushouldoutputtheirsuminoneline,andyoumustnotethatthereisablanklinebetweenoutputs. SampleInput 3 41234 512345 3123 SampleOutput 10 15 6 #include intmain() { intn,i,m,j; inta[100],count; scanf("%d",&n); for(i=0;i { count=0; scanf("%d",&m); for(j=0;j { scanf("%d",&a[j]); count+=a[j]; } printf("%d\n\n",count); } return0; } 求三个整数中最大的数 TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 134,Acceptedusers: 104 Problem10452: Nospecialjudgement Problemdescription 有三个整数a,b,c,请输出三个整数中最大的数。 Input 输入每行包含三个整数a,b,c,整数范围在-231 ~ +231-1之内。 Output 对于每行三个整数输出其中最大的整数,每组数据输出一行。 SampleInput 259 8241 SampleOutput 9 24 #include intmain() { longa,b,c; while(scanf("%ld%ld%ld",&a,&b,&c)! =EOF) { if(a>=b) { if(a>=c)printf("%d\n",a); elseprintf("%d\n",c); } else { if(b>=c)printf("%d\n",b); elseprintf("%d\n",c); } } return0; } 分段函数 TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 99,Acceptedusers: 63 Problem10453: Nospecialjudgement Problemdescription 有一函数 x (x<1) y= 2x-1 (1<=x<10) 3x-11 (x>=10) 编写程序根据x的值输出y的值。 Input 输入将包含若干组数据,第一行为一个整数n,代表下面共有n组数据。 接下来的每一行为一个x(共n行),代表一组数据。 Output 对于每组输入的数据x,输出其y值,每组数据输出一行。 计算结果如果为小数,小数点后保留1位有效数字,四舍五入。 SampleInput 2 5 30 SampleOutput 9 79 #include #include int main() { int n,i; double x; scanf("%d",&n); for(i=0;i { scanf("%lf",&x);//双精度输入一定要用%lf if(x<1) { if(x>floor(x)) printf("%.1f\n",x); else printf("%.0f\n",x); } else if(x>=1&&x<10) { if(2*x-1>floor(2*x-1)) printf("%.1f\n",2*x-1); else printf("%.0f\n",2*x-1); } else { if(3*x-11>floor(3*x-11)) printf("%.1f\n",3*x-11); else printf("%.0f\n",3*x-11); } } return 0; } 计算表达式的值 TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 70,Acceptedusers: 64 Problem10454: Nospecialjudgement Problemdescription 输入x、y和z的值,计算下面表达式的值。 (x+1)(y-3)/(x+y+Z) Input 输入包含若干组数据,第一行为一个整数n,代表下面共有n组数据。 接下来的每一行为一组数据,包括x,y,z,数据间用空格分隔。 Output 对于每组输入的数据,输出其表达时的值,小数点后面保留四位有效数字。 每组数据输出一行。 SampleInput 2 123 7820 SampleOutput -0.3333 1.1429 #include intmain() { intn; doublex,y,z; scanf("%d",&n); while(n--) { scanf("%lf%lf%lf",&x,&y,&z); printf("%.4f\n",(x+1)*(y-3)/(x+y+z)); } return0; } 求n的阶乘 TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 88,Acceptedusers: 79 Problem10455: Nospecialjudgement Problemdescription 从输入文件中读取一个数n,求出n! 。 Input 输入包含若干组数据,第一行上有一个整数m,指明接下来的数字的个数。 然后是m行,每一行包含一个确定的正整数n,1≤n≤10。 Output 对输入行中的每一个数据n,输出一行,其内容是n! 。 SampleInput 3 1 5 10 SampleOutput 1 120 3628800 #include intmain() { intm,n,i; longcount; scanf("%d",&m); while(m--) { count=1;//一定要在循环内初始化 scanf("%d",&n); if(n>=1&&n<=10)//有没有这个判断都行 { for(i=1;i<=n;i++) count*=i; printf("%ld\n",count); } } return0; } 阶乘问题 TimeLimit: 1000ms,SpecialTimeLimit: 2500ms,MemoryLimit: 32768KB Totalsubmitusers: 55,Acceptedusers: 47 Problem10457: Nospecialjudgement Problemdescription 从输入文件中读取一个数n,求出n! 中末尾0的个数。 Input 输入包含若干组数据。 第一行上有一个整数m,指明接下来的数字的个数。 然后是m行,每一行包含一个确定的正整数n,1≤n≤1000000000。 Output 对输入行中的每一个数据n,输
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- acm
![提示](https://static.bdocx.com/images/bang_tan.gif)