中国地质大学武汉第九届ACM程序设计大赛暨华中地区邀请赛试题.docx
《中国地质大学武汉第九届ACM程序设计大赛暨华中地区邀请赛试题.docx》由会员分享,可在线阅读,更多相关《中国地质大学武汉第九届ACM程序设计大赛暨华中地区邀请赛试题.docx(12页珍藏版)》请在冰豆网上搜索。
中国地质大学武汉第九届ACM程序设计大赛暨华中地区邀请赛试题
ProblemA.EasyProblem
TimeLimit:
3000MSMemoryLimit:
100000K
Description
Everyoneloveeasyproblem,sodoeswincat.Recentlywincatworryaboutgraduatefromschool.Theprofessorsaytowincat:
”consideryouaresuchalazyboy,nowgiveyouaquiteeasyproblem,Ifyoucaneithersolveitandthengraduateorwaitforanotheryear,nowhereisthequestion,Igaveyouaverybigintegerintenbase,findouthowmany1intheintegerwhenitistransformedtobinarybase”.Youknowitisquiteseriousproblemforwincat,pleasehelphim.
Input
Therewillbemultiplytest,eachtestbeginwithanumberN(1<=N<=10000)representsthedigitthebigIntegerhaveinaline,followingwiththebigIntegerinaline.
Output
Asingleintegerrepresentsthenumberof1inthebigIntegerwhenitistransformedtobinarybase.
SampleInput
10
1000000000
SampleOutput
13
ProblemB.BigDinner
TimeLimit:
5000MSMemoryLimit:
100000K
Description
Therewillbeabigdinnerinwincat’shome.Heisquitebusypreparingthedinner,buydifferentsizeofcircledish,vegetablesandvarymeats.Afterhehasalmostpreparedeverythingalready,differentsizesofdishwithvarydeliciousfoodsonthesquaretable.Suddenly,thepowercutout,andhehasnotfinishedthefinalstepofthepreparation—changestheplaceofsomedishtomakethebigmeallookbetter.Fortunately,wincathasalreadywrittendownallthecoordinateandradiusofeachplate.Eachtime,hecanjusttakeonedishoutandthenputitdownatanotherplaceofthetable(wecan’tletthedishoverlapandwejustneedtoputthecenterofthedishonthetable),Heassumethecoordinateofthesquaretableisatwo-dimcoordinatelikethepictureofbelow:
y
Squaretable
x
(0,0)
Althoughhehasthedata,therearetoomanydishesonthetablehecan’tdecideifthemoveofthedishislogical(thedishcan’toverlap).Youarethebestfriendofhimandalsoatalentprogrammer,couldyouhelphim?
Input
Therewillbemultiplytests,readuntiltheendoffile.Thefirstlineofeachtestaretwointegersize(0Output
Foreachoperationthewincatmove,tellheifhismovementislogical.IfitislogicaloutputtheIDofthedishwith”movesuccess!
”oroutputtheIDofthedishwith”movefail!
”.(ifthemoveisfail,thedishwillbeontheoriginplacewhereitis)
Outputextratwospacelineaftereachtestdata.
SampleInput
10103
2.502.502.48
7.502.502.48
2.507.502.48
3
02.507.50
27.507.50
02.507.50
SampleOutput
0failmove!
2successmove!
0successmove!
ProblemC.LengthofArc
TimeLimit:
1000MSMemoryLimit:
100000K
Description
Therearemanycirclesandalightspotontheplane.Allofcircledonotallowlighttogothroughthemandallofthemarenotintersect.Nowyoumusttocalculatethelengthofarewhichcanlightbythelightspot.
Input
Theinputcontainsmultipletestcases.Foreachtestcase:
Thefirstlineisanintegernumbern,indicatingthenumberofcircles,thennlinesfollowing,eachlinehasthreenumberx,y,r,indicatingthecoordinateofthecentreandradius.Thelastlineofeachtestcasecontainstwonumberindicatedthecoordinateofthelightspot.Allthenumbersinonelineareseparatedbyspaces.
Output
Foreachtestcase,outputonelinecontaininganumberwith3digitsafterdecimalpointrepresentingtheanswerdescribingabove.
SampleInput
2
201
804.5
00
SampleOutput
5.713
ProblemD.Consecutive-digitNumber
TimeLimit:
1000MSMemoryLimit:
100000K
Description
RecentlyGingerfoundthattherearemanynumbers,digitsofwhomcanberearrangedtoaconsecutivesequence.Forinstance,254310isaconsecutive-digitnumber,sincethedigitsofitare2,5,4,3,1and0,whichcanberearrangedto"0,1,2,3,4,5".
Asequenceisconsecutive,ifitformsaone-ascendingdigitsequenceeitherconsecutivelyorcircularlyfrom9to0.Forexample,both"1,2,3,4"and"8,9,0,1"areconsecutivesequences.
Theinitialzerosofagivennumberareofcourseomitted.
Input
Thereareseveralinputcases,asinglepositiveintegerinasinglelineforeachinputcase.Inputendwith0.
Output
YESorNOinasingleline,ifthegivennumberisaconsecutive-digitnumberornot.
SampleInput
1423
7980
21350
2100
0
SampleOutput
YES
YES
NO
NO
ProblemE.klongestpaths
TimeLimit:
4000MSMemoryLimit:
100000K
Description
Inadirectedacyclicgraph(DAG),therearenverticesandmedges.Foreachedge(i,j),itsubjectstoiInput
Therearemanydatasetintheinput.Thefirstlineineachdatasethasthreeintegernumbers.Thefirstintegernisthenumberofverticesinthegraph,thesecondonemisthenumberofedges,andthethirdisk(n<=100000,m<=200000andk<=1000).Followedthefirstlinearemlines,eachofthemhasthreeintegernumbersi,j,l,whichindicatesanedgefromitojwiththelengthofl.
Thelastdatasetisfollowedbyalinecontainingthreezeros.Twoormoreinputitemsinalineareseparatedbyaspace.
Output
Foreachdatasetintheinput,ifthenumberofdistinctpathsfrom0ton-1iskormore,youshouldoutputtheklongestpaths.First,yousortthesepathsbylengthfromlongtoshort.Iftwoormorepathsarethesamelength,youshouldsortthembyprefix.(Example:
PathA:
a1,a2,a3........as,PathB:
b1,b2,b3,.....bt,PathAandPathBhavethesamelength,thenPathAisoutputfirstifai=bi(1<=i<=k)anda[k+1]
Apathvisitingthesamevertextwiceormoreisnotpossible.
SampleInput
335
121
231
131
6710
0138
1220
2310
3460
2460
450
350
000
SampleOutput
None
128012345
11801245
6801235
ProblemF.Robots
TimeLimit:
4000MSMemoryLimit:
100000K
Description
Communicationisanimportantcomponentforrobotsworktogether.Now,thereareNrobotsintwo-dimensionalplane.Theircoordinatesare(x1,y1),...,(xn,yn).EachrobotcancommunicatewithotherrobotsthroughwirelessinamaximumEuclideandistanceD.Theserobotscanonlycommunicatewitheachotherdirectly.Communicatingotherrobotsthroughanagentrobotisnotallowed.Theproblemiscalculatingasetofrobotswithmaximumsize,everyrobotinthesetcancommunicatewithotherrobotsinthesetdirectly.
Input
ThefirstlineofinputisthenumbertestcaseT(T<=100).Ttestcasesfollow.EachtestcasebeginswithalinewithtwointegersN(2<=N<=200)andD.Nisthenumberofrobots,Disthemaximumcommunicatedistance.ThefollowedNlinesarecoordinatesofNrobots.Eachlineistwointegers(xi,yi),thecoordinateforroboti.
Output
Foreachtestcase,youshouldoutputalinewiththesizeofmaximumsetdescriptabove.
SampleInput
2
21
00
10
53
00
20
02
-20
0-2
SampleOutput
2
3
ProblemG.Network
TimeLimit:
1000MSMemoryLimit:
100000K
Description
IfyouhadparticipatedinCUGPC(CUGProgrammingContest)2009or2010,youmayberememberwehadproblemstotransferdatainacomputernetwork.Thisyear,wefoundanewdifficultproblem.Thisproblemis:
Therearesomecomputersinthecomputerroom,whichareplacedinacirclewayandeverytwoneighboringcomputersareconnectedbylocalareanetwork.Eachcomputercanexchangedatawiththeneighborone.However,thesignalstrengthwouldweakenaftertransferonthenetwork.Andeverycomputercantransferdatatoallcomputers(includethecomputeritself)clockwiseoranti-clockwisearoundthecircle.Thefigurebelowshowsthefirsttestcaseofsampleinput.
Input
Theinputconsistsofmultipletestcases.Foreachtestcase,thefirstlinecontainsaintegerN(2<=N<=500000),thenumberofcomputer,followedbytwolines.EachlinecontainsNintegers.Andtheithnumberofthesecondline,inincreasingorder,indicatesthedistancebetweencomputeriandcomputeri+1.TheNthdistanceindicatesthedistancebetweencomputerNandcomputeri.
Output
Foreachtestcase,output2line.Thefirstlineisthenumberofnodescantransferdataaroundthecircleornot.Thesecondlineisidsofthesenodesinincreasingorder.
SampleInput
5
31505
12214
SampleOutput
3
135
ProblemH.SuperFour
TimeLimit:
1000MSMemoryLimit:
100000K
Description
Lvyunisattractedbycryptographyrecently.Hewantstoinventthestrongestencryptionalgorithminthehistory.Numbertheoryisafundamentalofcryptography.Inhisalgorithm,alotofnumbertheoriesareused.However,Lvyunispoorinmath.Hewantstoaskyou,thesmartestprogrammerin