版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
計(jì)算機(jī)工程學(xué)院第三屆ACM程序設(shè)計(jì)大賽試題ProblemABridgeDescriptionnpeoplewishtocrossabridgeatnight.Agroupofatmosttwopeoplemaycrossatanytime,andeachgroupmusthaveaflashlight.Onlyoneflashlightisavailableamongthenpeople,sosomesortofshuttlearrangementmustbearrangedinordertoreturntheflashlightsothatmorepeoplemaycross.Eachpersonhasadifferentcrossingspeed;thespeedofagroupisdeterminedbythespeedoftheslowermember.Yourjobistodetermineastrategythatgetsallnpeopleacrossthebridgeintheminimumtime.InputThefirstlineofinputcontainsn,followedbynlinesgivingthecrossingtimesforeachofthepeople.Therearenotmorethan1000peopleandnobodytakesmorethan100secondstocrossthebridge.OutputThefirstlineofoutputmustcontainthetotalnumberofsecondsrequiredforallnpeopletocrossthebridge.Thefollowinglinesgiveastrategyforachievingthistime.Eachlinecontainseitheroneortwointegers,indicatingwhichpersonorpeopleformthenextgrouptocross.(Eachpersonisindicatedbythecrossingtimespecifiedintheinput.Althoughmanypeoplemayhavethesamecrossingtimetheambiguityisofnoconsequence.)Notethatthecrossingsalternatedirections,asitisnecessarytoreturntheflashlightsothatmoremaycross.Ifmorethanonestrategyyieldstheminimaltime,anyonewilldo.SampleInput(Inputfile:pa.txt )412510SampleOutput1721012ProblemBLottoDescriptionIntheGermanLottoyouhavetoselect6numbersfromtheset{1,2,...,49}.ApopularstrategytoplayLotto-althoughitdoesn'tincreaseyourchanceofwinning-istoselectasubsetScontainingk(k>6)ofthese49numbers,andthenplayseveralgameswithchoosingnumbersonlyfromS.Forexample,fork=8andS={1,2,3,5,8,13,21,34}thereare28possiblegames:[1,2,3,5,8,13],[1,2,3,5,8,21],[1,2,3,5,8,34],[1,2,3,5,13,21],...[3,5,8,13,21,34].YourjobistowriteaprogramthatreadsinthenumberkandthesetSandthenprintsallpossiblegameschoosingnumbersonlyfromS.InputTheinputwillcontainoneormoretestcases.Eachtestcaseconsistsofonelinecontainingseveralintegersseparatedfromeachotherbyspaces.Thefirstintegeronthelinewillbethenumberk(6<k<13).Thenkintegers,specifyingthesetS,willfollowinascendingorder.Inputwillbeterminatedbyavalueofzero(0)fork.OutputForeachtestcase,printallpossiblegames,eachgameononeline.Thenumbersofeachgamehavetobesortedinascendingorderandseparatedfromeachotherbyexactlyonespace.Thegamesthemselveshavetobesortedlexicographically,thatmeanssortedbythelowestnumberfirst,thenbythesecondlowestandsoon,asdemonstratedinthesampleoutputbelow.Thetestcaseshavetobeseparatedfromeachotherbyexactlyoneblankline.Donotputablanklineafterthelasttestcase.SampleInput (Inputfile:pb.txt )712345678123581321340SampleOutput123456123457123467123567124567134567234567123581312358211235834123513211235133412352134123813211238133412382134123132134125813211258133412582134125132134128132134135813211358133413582134135132134138132134158132134235813212358133423582134235132134238132134258132134358132134ProblemCEncryptChipandDalehavedevisedanencryptionmethodtohidetheir(written)textmessages.Theyfirstagreesecretlyontwonumbersthatwillbeusedasthenumberofrows(R)andcolumns(C)inamatrix.Thesenderencodesanintermediateformatusingthefollowingrules:Thetextisformedwithuppercaseletters[A-Z]and<space>.Eachtextcharacterwillberepresentedbydecimalvaluesasfollows:<space>=0,A=1,B=2,C=3,...,Y=25,Z=26Thesenderentersthe5digitbinaryrepresentationofthecharacters'valuesinaspiralpatternalongthematrixasshownbelow.Thematrixispaddedoutwithzeroes(0)tofillthematrixcompletely.Forexample,ifthetexttoencodeis:"ACM"andR=4andC=4,thematrixwouldbefilledinasfollows:0000110100101100A=00001,C=00011,M=01101(oneextra0)Thebitsinthematrixarethenconcatenatedtogetherinrowmajororderandsenttothereceiver.Theexampleabovewouldbeencodedas:0000110100101100InputThefirstlineofinputcontainsa singleintegerN,(1follow.EachdatasetconsistsofasinglelineofinputcontainingR(1
≤
N
≤
1000)whichisthenumberofdatasetsthat≤R ≤20),aspace,C(1space,andastringofbinarydigitsthatrepresentsthecontentsofthematrix(R*Cbinarydigits).Thebinarydigitsareinrowmajororder.OutputForeachdataset,youshouldgenerateonelineofoutputwiththefollowingvalues:Thedatasetnumberasadecimalinteger(startcountingatone),aspace,andthedecodedtextmessage.Youshouldthrowawayanytrailingspacesand/orpartialcharactersfoundwhiledecoding.SampleInput(Inputfile:pc.txt )244ACM52HISampleOutput00001101001011000110000010ProblemDConnectionThereareNcitiesinthecountryandMbidirectionalroadsbetweenthecities.Thegovernmentwantstobuildsomenewroadssuchthatforanypairofcitiesthereisatleastonepathbetweenthem.Nowyouhavetofindouttheminimalamountofroadsthathavetobuild.InputTheinputmaycontainmultipletestcases.Foreachtestcase,thefirstlineistwointegersN(1<=N<=100)andM(1<=M<=N*N/2),indicatingthenumberofcitiesandthenumberofroads.ThenthenextMlineseachcontaintwointegersxandy(0<=x,y<n),meaningthatthereisaroadbetweencitiesxandcitiesy.N=M=0indicatestheendofinput.OutputForeachtestcase,printtheanswerinasingleline.SampleInput(Inputfile:pd.txt )213SampleOutput2ProblemE GridlandBackgroundForyears,computerscientistshavebeentryingtofindefficientsolutionstodifferentcomputingproblems.Forsomeofthemefficientalgorithmsarealreadyavailable,thesearethe"easy"problemslikesorting,evaluatingapolynomialorfindingtheshortestpathinagraph.Forthe"hard"onesonlyexponential-timealgorithmsareknown.Thetraveling-salesmanproblembelongstothislattergroup.GivenasetofNtownsandroadsbetweenthesetowns,theproblemistocomputetheshortestpathallowingasalesmantovisiteachofthetownsonceandonlyonceandreturntothestartingpoint.ProblemThepresidentofGridlandhashiredyoutodesignaprogramthatcalculatesthelengthoftheshortesttraveling-salesmantourforthetownsinthecountry.InGridland,thereisonetownateachofthepointsofarectangulargrid.RoadsrunfromeverytowninthedirectionsNorth,Northwest,West,Southwest,South,Southeast,East,andNortheast,providedthatthereisaneighbouringtowninthatdirection.ThedistancebetweenneighbouringtownsindirectionsNorth?CSouthorEast?CWestis1unit.ThelengthoftheroadsismeasuredbytheEuclideandistance.Forexample,Figure7shows2??3-Gridland,i.e.,arectangulargridofdimensions2by3.In2??3-Gridland,theshortesttourhaslength6.Figure7:Atraveling-salesmantourin2 ??3-Gridland.InputThefirstlinecontainsthenumberofscenarios.Foreachscenario,thegriddimensionsmandnwillbegivenastwointegernumbersinasingleline,separatedbyasingleblank,satisfying1<m<50and1<n<50.OutputTheoutputforeachscenariobeginswithalinecontaining"Scenario#i:",whereiisthenumberofthescenariostartingat1.Inthenextline,printthelengthoftheshortesttraveling-salesmantourroundedtotwodecimaldigits.Theoutputforeveryscenarioendswithablankline.SampleInput(Inputfile:pe.txt )223SampleOutputScenario#1:4.00Scenario#2:6.00ProblemFDigitalRootsBackgroundThedigitalrootofapositiveintegerisfoundbysummingthedigitsoftheinteger.Iftheresultingvalueisasingledigitthenthatdigitisthedigitalroot.Iftheresultingvaluecontainstwoormoredigits,thosedigitsaresummedandtheprocessisrepeated.Thisiscontinuedaslongasnecessarytoobtainasingledigit.Forexample,considerthepositiveinteger24.Addingthe2andthe4yieldsavalueof6.Since6isasingledigit,6isthedigitalrootof24.Nowconsiderthepositiveinteger39.Addingthe3andthe9yields12.Since12isnotasingledigit,theprocessmustberepeated.Addingthe1andthe2yeilds3,asingledigitandalsothedigitalrootof39.InputTheinputfilewillcontainalistofpositiveintegers,oneperline.Theendoftheinputwillbeindicatedbyanintegervalueofzero.OutputForeachintegerintheinput,outputitsdigitalrootonaseparatelineoftheoutput.Sampleinput(Inputfile:pf.txt )24390SampleOutput63ProblemGCountingNumbersStartingfromapositiveintegern(1<=n<=2001).Ontheleftoftheintegern,youcanplaceanotherintegermtoformanewintegermn,wheremmustbelessthenorequaltohalfoftheintegern,Ifthereisanintegerklessthenorequaltohalfofm,youcanplaceintegerkontheleftofmn,toformanewintegerkmn,,andsoon.ForExamole,youcanplace12ontheleftof30toFormaninteger1230,andyoucanplace6totheleftof1230toformaninteger61230,,andsoonForexample,startfromn=8.youcanplaceinteger1,2,3and4totheleftof8togettheintegers18,28,38,48.Fornumber18,youcannotformanewintegerusingtheproceduredescribedasabove.Fornumber28and38,youcanformnewintegers128and138.Fornumber48,youcanplace1and2ontheleftof48togetnewintegers148and248.Fornumber248,youcanplace1ontheleftofittogetanewinteger1248.Intotal,youcanhavethefollowing10integers(includeingtheintegeryoustartwith)8182838481281381482481248Giveanintegern,findthenumberofintegersyoucangetusingtheproceduredescribedabove.InputAnintegernOutputAnintegerwitchrepresentsthenumberofintegeryoucanget.Sampleinput: (Inputfile:pg.txt )8SampleOutput:10ProblemHBuyLow,BuyLowerTheadviceto"buylow"ishalftheformulatosuccessinthestockmarket.Buttobeconsideredagreatinvestoryoumustalsofollowthisproblems'advice:"Buylow,buylower"Thatis,eachtimeyoubuyastock,youmustpurchasemoreatalowerpricethantheprevioustimeyouboughtit.Themoretimesyoubuyatalowerpricethanbefore,thebetter!Yourgoalistoseehowmanytimesyoucancontinuepurchasingateverlowerprices.Youwillbegiventhedailysellingpricesofastockoveraperiodoftime.Youcanchoosetobuystockonanyofthedays.Eachtimeyouchoosetobuy,thepricemustbelowerthantheprevioustimeyouboughtstock.Writeaprogramwhichidentifieswhichdaysyoushouldbuystockinordertomaximizethenumberoftimesyoubuy.Bywayofexample,supposeonsuccessivedaysstockissellinglikethis:Day12345
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五版綠色能源項(xiàng)目水電設(shè)施承包合同3篇
- 二零二五年架子工工程綠色施工技術(shù)指導(dǎo)合同模板2篇
- 2025版人工智能項(xiàng)目提成協(xié)議書(shū)(技術(shù)成果轉(zhuǎn)化提成合同)3篇
- 二零二五年度太陽(yáng)能光伏電站安裝與運(yùn)營(yíng)管理合同3篇
- 2025年度深井鉆井工程環(huán)保驗(yàn)收合同4篇
- 二零二五年度房地產(chǎn)交易風(fēng)險(xiǎn)預(yù)警協(xié)議3篇
- 2025餐飲業(yè)三人合作開(kāi)發(fā)新菜品協(xié)議2篇
- 2025年度水庫(kù)魚(yú)塘漁業(yè)養(yǎng)殖與漁業(yè)保險(xiǎn)合作承包合同4篇
- 泥工包工2025年度合同范本2篇
- 二零二五年車(chē)牌指標(biāo)租賃與汽車(chē)租賃服務(wù)合同3篇
- 《健康體檢知識(shí)》課件
- 部編版語(yǔ)文五年級(jí)下冊(cè) 第一單元 專(zhuān)項(xiàng)訓(xùn)練課外閱讀(含答案)
- 蘇少版七年級(jí)美術(shù)下冊(cè) 全冊(cè)
- 名表買(mǎi)賣(mài)合同協(xié)議書(shū)
- JTG-T-F20-2015公路路面基層施工技術(shù)細(xì)則
- 2024年遼寧石化職業(yè)技術(shù)學(xué)院?jiǎn)握新殬I(yè)適應(yīng)性測(cè)試題庫(kù)附答案
- 中西方校服文化差異研究
- 《子宮肉瘤》課件
- 《準(zhǔn)媽媽衣食住行》課件
- 給男友的道歉信10000字(十二篇)
- 客人在酒店受傷免責(zé)承諾書(shū)范本
評(píng)論
0/150
提交評(píng)論