科技文化节程序设计竞赛题.docx
《科技文化节程序设计竞赛题.docx》由会员分享,可在线阅读,更多相关《科技文化节程序设计竞赛题.docx(10页珍藏版)》请在冰豆网上搜索。
科技文化节程序设计竞赛题
P1:
进制转化
TimeLimit:
1000MS MemoryLimit:
16000K
Description
输入一个十进制数,转化成十六进制数,然后输出。
Input
含有多组测试数据,每组测试数据仅一个正整数N(N<109),表示十进制数,读文件结束。
Output
对每个测试用例,输出N对应的十六进制数。
SampleInput
11
25
SampleOutput
B
19
P2:
硬币问题
TimeLimit:
1000MS MemoryLimit:
16000K
Description
小明有n(n<=30)枚硬币,每一枚硬币的面值不等。
小明现在想要用这些硬币拼出一个最大的价值M,且1到M之间所有的数都能用这些硬币拼出来,对于组一个数,每一枚硬币只能用一次,不能多次使用。
现在小明需要你帮他确定这个最大价值M,以及每枚硬币的面值。
例如n=2时,最大价值为3,两枚硬币分别为1,2,这样1由1组成,2由2组成,3由1和2组成。
Input
含有多组测试数据,每组测试数据仅一个正整数n,读文件结束。
Output
对每个测试用例,输出两行。
第一行输出M。
第二行输出每一枚硬币的面值,从小到大排序,每个面值中间用空格隔开。
SampleInput
2
SampleOutput
3
12
P3:
BoneCollector
TimeLimit:
1000MS MemoryLimit:
16000K
Description
Manyyearsago,inTeddy’shometowntherewasamanwhowascalled“BoneCollector”.Thismanliketocollectvariesofbones,suchasdog’s,cow’s,alsohewenttothegrave…
ThebonecollectorhadabigbagwithavolumeofV,andalonghistripofcollectingtherearealotofbones,obviously,differentbonehasdifferentvalueanddifferentvolume,nowgiventheeachbone’svaluealonghistrip,canyoucalculateoutthemaximumofthetotalvaluethebonecollectorcanget?
Input
ThefirstlinecontainaintegerT,thenumberofcases.
FollowedbyTcases,eachcasethreelines,thefirstlinecontaintwointegerN,V,(N<=1000,V<=1000)representingthenumberofbonesandthevolumeofhisbag.AndthesecondlinecontainNintegersrepresentingthevalueofeachbone.ThethirdlinecontainNintegersrepresentingthevolumeofeachbone.
Output
Oneintegerperlinerepresentingthemaximumofthetotalvalue(thisnumberwillbelessthan231).
SampleInput
1
510
12345
54321
SampleOutput
14
P4:
母猪的故事
TimeLimit:
1000MS MemoryLimit:
16000K
Description
话说现在猪肉价格这么贵,著名的ACBoy0068也开始了养猪生活。
说来也奇怪,他养的猪一出生第二天开始就能每天中午生一只小猪,而且生下来的竟然都是母猪。
不过光生小猪也不行,0068采用了一个很奇特的办法来管理他的养猪场:
对于每头刚出生的小猪,在他生下第二头小猪后立马被杀掉,卖到超市里。
假设在创业的第一天,0068只买了一头刚出生的小猪,请问,在第N天晚上,0068的养猪场里还存有多少头猪?
Input
测试数据的第一行包含有一个正整数T,代表测试数据的个数。
接下来有T组测试,每组测试数据占一行,分别有一个正整数N代表0068创业的第N天。
(0Output
对于每组数据,请在一行里输出第N天晚上养猪场里猪的数目。
SampleInput
2
3
2
SampleOutput
2
3
P5:
OilDeposits
TimeLimit:
1000MS MemoryLimit:
16000K
Description
TheGeoSurvCompgeologicsurveycompanyisresponsiblefordetectingundergroundoildeposits.GeoSurvCompworkswithonelargerectangularregionoflandatatime,andcreatesagridthatdividesthelandintonumeroussquareplots.Itthenanalyzeseachplotseparately,usingsensingequipmenttodeterminewhetherornottheplotcontainsoil.Aplotcontainingoiliscalledapocket.Iftwopocketsareadjacent,thentheyarepartofthesameoildeposit.Oildepositscanbequitelargeandmaycontainnumerouspockets.Yourjobistodeterminehowmanydifferentoildepositsarecontainedinagrid.
Input
Theinputfilecontainsoneormoregrids.Eachgridbeginswithalinecontainingmandn,thenumberofrowsandcolumnsinthegrid,separatedbyasinglespace.Ifm=0itsignalstheendoftheinput;otherwise1<=m<=100and1<=n<=100.Followingthisaremlinesofncharacterseach(notcountingtheend-of-linecharacters).Eachcharactercorrespondstooneplot,andiseither`*',representingtheabsenceofoil,or`@',representinganoilpocket.
Output
Foreachgrid,outputthenumberofdistinctoildeposits.Twodifferentpocketsarepartofthesameoildepositiftheyareadjacenthorizontally,vertically,ordiagonally.Anoildepositwillnotcontainmorethan100pockets.
SampleInput
11
*
35
*@*@*
**@**
*@*@*
18
@@****@*
00
SampleOutput
0
1
2
P6:
Thekthgreatnumber
TimeLimit:
1000MS MemoryLimit:
16000K
Description
XiaoMingandXiaoBaoareplayingasimpleNumbersgame.
InaroundXiaoMingcanchoosetowritedownanumber,oraskXiaoBaowhatthekthgreatnumberis.
BecausethenumberwrittenbyXiaoMingistoomuch,XiaoBaoisfeelinggiddy.Now,trytohelpXiaoBao.
Input
Thereareseveraltestcases.Foreachtestcase,thefirstlineofinputcontainstwopositiveintegern,k.Thennlinesfollow.
IfXiaoMingchoosetowritedownanumber,therewillbean"I"followedbyanumberthatXiaoMingwillwritedown.
IfXiaoMingchoosetoaskXiaoBao,therewillbea"Q",thenyouneedtooutputthekthgreatnumber.
Output
Theoutputconsistsofoneintegerrepresentingthelargestnumberofislandsthatalllieononeline.
SampleInput
83
I1
I2
I3
Q
I5
Q
I4
Q
SampleOutput
1
2
3
P7:
救援物资
TimeLimit:
1000MS MemoryLimit:
16000K
Description
台风“尤特”来袭,给广东带来大范围降雨,在潮汕某些地区地势较低,大水淹没了一些村庄,造成了交通的中断。
村民们已经2天没有食物供应了,救援队只能通过飞机投放救援物质。
飞机从A(0,y)出发以v米/秒速度匀速平行于X轴飞行,离投放区域的高度为h米,到达B(x,y)点进行投放。
假设重力加速度g=10米/秒^2,相邻坐标相隔为1米。
为了让投放的物资必须要投放到没有被大水淹没的高地上(高地任何一个位置都是平坦的),您必须编写一个程序,按顺时针顺序输入高地的一些直线交点的坐标,计算物资是否能够准确落在高地上。
物资投放过程中忽略其他因素,包括风速,落在边缘位置也算投放成功。
Input
第一行包含高地边缘坐标点的数目N;
第2~N+1行,包含每个坐标点(x1,y1);
第N+2行,飞机投放的坐标,高度,速度(x,y,h,v)
包含多组测试样例。
Output
投放成功,输出success
投放失败,输出fail
SampleInput
8
8.011.0
11.07.0
10.04.0
5.01.0
2.03.0
4.05.0
4.09.0
5.08.0
7.09.05.01.0
SampleOutput
success
P8:
取余运算
TimeLimit:
1000MS MemoryLimit:
16000K
Description
输入b,p,k的值,求b^pmodk的值。
其中b,p,k*k为长整型数。
Input
含有多组测试数据,每组测试数据包含3个数据,即b,p,k(b,p,k<2^32)。
Output
对每个测试用例,输出所求运算的余数。
SampleInput
2109
SampleOutput
7
P9:
逃离神庙
TimeLimit:
3000MS MemoryLimit:
16000K
Description
有批游客在非洲旅游的时候不小心误闯了某部落禁地神庙里,进了禁地后他们被分散到了神庙的不同方位。
神庙里有一些门可以传送他们离开,但是每个门只能传送一个人,传送完毕后门的传送魔法就会失效,变成一个石块。
他们必须找到属于自己最近的门,并且尽可能的让所有人以最快时间离开神庙,否则时间长了被部落的人发现会有生命危险.
逃离的过程中会有石块阻碍,不能越过。
每走一个坐标耗时为1s。
Input
第一行包含矩阵的大小N,M(2<=N,M<200),游客的数量P(1<=P<=20),门的数量D(1<=D<=30),石块的数量S;
接下来,每行包含P个游客的坐标点(i1,j1);
再接下来,每行包含D个门的坐标点(i2,j2);
最后,每行包含S个石块的坐标点(i3,j3)
包含多组测试样例。
Output
对逃离成功,输出所有人最快逃出神庙的时间总和。
逃离失败,输出impossible。
SampleInput
711222
23
45
27
68
15
25
SampleOutput
11