08年acm浙江省题目Word文档下载推荐.docx

上传人:b****1 文档编号:5227946 上传时间:2023-05-04 格式:DOCX 页数:24 大小:93.59KB
下载 相关 举报
08年acm浙江省题目Word文档下载推荐.docx_第1页
第1页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第2页
第2页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第3页
第3页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第4页
第4页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第5页
第5页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第6页
第6页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第7页
第7页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第8页
第8页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第9页
第9页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第10页
第10页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第11页
第11页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第12页
第12页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第13页
第13页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第14页
第14页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第15页
第15页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第16页
第16页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第17页
第17页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第18页
第18页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第19页
第19页 / 共24页
08年acm浙江省题目Word文档下载推荐.docx_第20页
第20页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

08年acm浙江省题目Word文档下载推荐.docx

《08年acm浙江省题目Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《08年acm浙江省题目Word文档下载推荐.docx(24页珍藏版)》请在冰点文库上搜索。

08年acm浙江省题目Word文档下载推荐.docx

7'

(e.g.7,17,27,...),heshallsay"

insteadofthenumberitself.

Forexample,4studentsplaythisgame.Atsometime,thefirstonesays25,thenthesecondshouldsay26.Thethirdshouldsay"

because27containsthedigit'

.Thefourthoneshouldsay"

too,because28isamultipleof7.Thenthefirstonesays29,andthegamegoeson.Whensomeonemakesamistake,thegameends.

Duringagame,youmayhearaconsecutiveofp"

s.Sowhatistheminimumnumberthatcanmakethissituationhappen?

Forexamplep=2,thatmeansthereareaconsecutiveof2"

s.Thissituationhappensin27-28asstatedabove.27isthentheminimumnumbertomakethissituationhappen.

Input

Standardinputwillcontainmultipletestcases.ThefirstlineoftheinputisasingleintegerT(1<

=T<

=100)whichisthenumberoftestcases.AnditwillbefollowedbyTconsecutivetestcases.

Thereisonlyonelineforeachcase.Thelinecontainsonlyoneintegerp(1<

=p<

=99).

Output

Resultsshouldbedirectedtostandardoutput.Theoutputofeachtestcaseshouldbeasingleintegerinoneline,whichistheminimumpossiblenumberforthefirstofthep"

sstandsfor.

SampleInput

2

3

SampleOutput

27

70

二、BuildTheElectricSystem

198 

75 

Inlastwinter,therewasabigsnowstorminSouthChina.Theelectricsystemwasdamagedseriously.Lotsofpowerlineswerebrokenandlotsofvillageslostcontactwiththemainpowergrid.Thegovernmentwantstoreconstructtheelectricsystemassoonaspossible.So,asaprofessionalprogrammer,youareaskedtowriteaprogramtocalculatetheminimumcosttoreconstructthepowerlinestomakesurethere'

satleastonewaybetweeneverytwovillages.

Input

=50)whichisthenumberoftestcases.AnditwillbefollowedbyTconsecutivetestcases.

Ineachtestcase,thefirstlinecontainstwopositiveintegersNandE(2<

=N<

=500,N<

=E<

=N*(N-1)/2),representingthenumberofthevillagesandthenumberoftheoriginalpowerlinesbetweenvillages.TherefollowElines,andeachofthemcontainsthreeintegers,A,B,K(0<

=A,B<

N,0<

=K<

1000).AandBrespectivelymeanstheindexofthestartingvillageandendingvillageofthepowerline.IfKis0,itmeansthislinestillworksfineafterthesnowstorm.IfKisapositiveinteger,itmeansthislinewillcostKtoreconstruct.Therewillbeatmostonelinebetweenanytwovillages,andtherewillnotbeanylinefromonevillagetoitself.

Output

Foreachtestcaseintheinput,there'

sonlyonelinethatcontainstheminimumcosttorecovertheelectricsystemtomakesurethatthere'

SampleInput

1

33

015

020

129

SampleOutput

5

三、ColorfulRainbows

Evelynlikesdrawingverymuch.Today,shedrawslotsofrainbowsonwhitepaperofinfinitesize,eachusingadifferentcolor.Sincethere'

retoomanyrainbowsnow,shewonders,howmanyofthemcanbeseen?

Forsimplicity,eachrainbowLiisrepresentedasanon-verticallinespecifiedbytheequation:

y=aix+bi.ArainbowLicanbeseenifthereexistssomex-coordinatex0atwhich,itsy-coordinateisstrictlygreaterthany-coordinatesofanyotherrainbows:

aix0+bi>

ajx0+bjforallj!

=i.

Now,yourtaskis,giventhesetofrainbowsdrawn,figureoutthenumberofrainbowsthatcanbeseen.

=60)whichisthenumberoftestcases.AnditwillbefollowedbyTconsecutivetestcases.

There'

sablanklinebeforeeverycase.Ineachtestcase,therewillfirstbeanintegern(1<

=n<

=5000),whichisthenumberofrainbows.Thennconsecutiverealnumberpairsfollow.Eachpaircontainstworealnumbers,aiandbi,representingrainbowLi:

y=aix+bi.Notworainbowswillbethesame,thatistosay,havethesameaandb.

Resultsshouldbedirectedtostandardoutput.Theoutputofeachtestcaseshouldbeasingleinteger,whichisthenumberofrainbowsthatcanbeseen.

11

10

20

30

四、DifferenceGame

Nowyouaregoingtoplayaninterestinggame.Inthisgame,youaregiventwogroupsofdistinctintegersandCcoins.Thetwogroups,namedGaandGbrespectively,arenotemptyandcontainthesamenumberofintegersatfirst.Eachtimeyoucanmoveoneintegerinonegrouptotheothergroup.Butamovethatmakesagroupemptyisconsideredasinvalid.Eachmovewillcostyoupcoins,andpequalsthedifferenceofthesizebetweenthetwogroup(taketheabsolutevalue.e.g.movinganumberfromthegroupofsize4tothegroupofsize6willcostyou|4-6|=2coins,andmovinganumberbetweentwogroupwithsamesizewillnotcostanycoins).Youcandoasmanymovesasyouwish,solongasthetotalcostdoesnotexceedC.

LetMbetheminimumintegerinGa,andNbethemaximumintegerinGb.Thepurposeofthisgameistoproduceamaximum(M-N).

EachcasebeginwithtwointegersS(1<

=S<

=20000,indicatingthesizeofGaandGbatfirst)andC(0<

=C<

=1000000).TwolinesofSintegersfollow,representingthenumbersinGaandGbrespectively.Alltheseintegersaredistinctandarebetween1and50000,bothinclusive.

Resultsshouldbedirectedtostandardoutput.Theoutputofeachtestcaseshouldbeasingleintegerinoneline,whichisthemaximumpossiblevalueforM-Naftersomemoves.

110

10

12

210

12

34

-2

Hint

ForSample1,twogroupsareofsize1,sonomovescanbedonebecauseanymovingwillmakeGaorGbempty,whichisnotvalid.SoM=10,N=12,M-N=-2.

ForSample2,onevalidstepsofmovesis:

Move1inGatoGb,cost0coins.

Move3inGbtoGa,cost2coins.

Move4inGbtoGa,cost0coins.

ThenGacontains234,Gbcontains1,M=2,N=1,M-N=1.Thisisthemaximumpossiblevalue.

五、EasyTask

213 

126 

Calculatingthederivationofapolynomialisaneasytask.Givenafunctionf(x),weuse(f(x))'

todenoteitsderivation.Weusex^ntodenotexn.Tocalculatethederivationofapolynomial,youshouldknow3rules:

(1)(C)'

=0whereCisaconstant.

(2)(Cx^n)'

=C*n*x^(n-1)wheren>

=1andCisaconstant.

(3)(f1(x)+f2(x))'

=(f1(x))'

+(f2(x))'

.

Itiseasytoprovethatthederivationapolynomialisalsoapolynomial.

Herecomestheproblem,givenapolynomialf(x)withnon-negativecoefficients,canyouwriteaprogramtocalculatethederivationofit?

=1000)whichisthenumberoftestcases.AnditwillbefollowedbyTconsecutivetestcases.

Thereareexactly2linesineachtestcase.ThefirstlineofeachtestcaseisasinglelinecontaininganintegerN(0<

=100).ThesecondlinecontainsN+1non-negativeintegers,CN,CN-1,...,C1,C0,(0<

=Ci<

=1000),whicharethecoefficientsoff(x).Ciisthecoefficientofthetermwithdegreeiinf(x).(CN!

=0)

Foreachtestcasecalculatetheresultpolynomialg(x)alsoinasingleline.

(1)Ifg(x)=0justoutputinteger0.otherwise

(2)supposeg(x)=Cmx^m+Cm-1x^(m-1)+...+C0(Cm!

=0),thenoutputtheintegersCm,Cm-1,...C0.

(3)Thereisasinglespacebetweentwointegersbutnospacesafterthelastinteger.

321

10012

62

3001

六、Faster,Higher,Stronger

205 

145 

Intheyear2008,the29thOlympicGameswillbeheldinBeijing.ThiswillsignifytheprosperityofChinaandBeijingOlympicsistobeafestivalforpeopleallovertheworldaswell.

ThemottoofOlympicGamesis"

Citius,Altius,Fortius"

whichmeans"

Faster,Higher,Stronger"

.

Inthisproblem,therearesomerecordsintheOlympicGames.Yourtaskistofindoutwhichoneisfaster,whichoneishigherandwhichoneisstronger.

Eachtestcasehas3lines.Thefirstlineisthetypeoftherecords,whichcanonlybe"

Faster"

"

Higher"

or"

Stronger"

.ThesecondlineisapositiveintegerNmeaningthenumberoftherecordsinthistestcase.ThethirdlinehasNpositiveintegers,i.e.therecordsdata.Alltheintegersinthisproblemaresmallerthan2008.

Resultsshouldbedirectedtosta

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 商务科技

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2