版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
Theonestoremain
TimeLimit:1000ms,SpecialTimeLimit:2500ms,MemoryLimit:32768KBProblem11135:Nospecialjudgement
Problemdescription
ThereareNsoldiersstandinginoneline.Theyaremarkedfrom1toN,fromrighttoleft.Andtheyaregivenanumberm.Thenthesoldiersnumberedoff,straightfromtheright-handman.Theonewhoreportedanumberthatisthemultipleofmwaskeptintheline.Othershavetoleavetheline.Theycontinuedoingthistillthenumberofpeopleinthelineislessthanm.Forexample,ifthereare10soldiers,andm=3.Forthefirsttimethesoldierswhoaremarked3,6,9remainintheline.Forthesecondtimethesoldierwhoismarked9remainsintheline.Becausethenumberofsoldiersinthelineislessthanm,sothesoldiermarked9wastheonlyonetoremainintheline.
Nowwewanttoknowwhowillbetheonestoremain,canyoutellus?
Input
Thereareseveraltestcasesintheinput.Eachtestcasesisonlyoneline,containstwointegersnandm.(3<=n<=109,2<=m<=n).Theinputendswhenn=0andm=0.
Output
Foreachtestcase,outputtwolines.Thefirstlinecontainsoneintegerx,thenumberofsoldierstoremain.Thesecondlinecontainsxintegers,thenumbersmarkedonthesoldierswhoremainintheline.Youshouldoutputtheminincreasingorder.
SampleInput
103
83
00
SampleOutput
1
9
2
36
NumberGuessing
TimeLimit:1000ms,SpecialTimeLimit:2500ms,MemoryLimit:32768KBProblem11146:Nospecialjudgement
Problemdescription
NumberGuessingisacomputergame.First,thecomputerchoosesfourdifferentdigits,youneedtoguessthesefourdigitsinthefewesttimes,foreachguess,thecomputerwillshowajudgementintheformof"#A#B","#"isanumber0~4."#A"showshowmanydigitsyouguessedwithbothcorrectvalueandposition."#B"showshowmanydigitsyouguessedwithcorrectvalue.Forexample,thecomputerchose1234,andyouguessed6139,thecomputerwillshow"1A2B"foryouhavenumber"1"correctvaluebutwrongpositionandnumber"3"correctvaluewithcorrectposition.Thusthecomputergivesyouthejudgementof"1A2B"
Nowyouhavememorizedthedigitsyouguessedandthejudgementsyougot,youfeellikeyoucanfigureoutthecorrectanswer.Lifeisfilledwithwisdom,isn'tit?
Input
Thereareseveraltestcases.Foreachtestcase,thefirstlinecontainsasinglepositiveintegerNindicatesthetimesyoucanguess,thefollowingNlinesistherecordoftheguess,intheform:
#####A#B
Thefirstfournumbersisthenumbersguessed,thenthejudgementsforyourguess.TheinputterminatedwhenNisnotpostiveinteger,andnotneedtoproceed.
Output
Foreachtestcase,outputasinglelinecontainsexactlyfourdigitsthatthecomputerhaschosen.Youmayassumethateachtestcasegivesyouenoughinformation,soyoucanfigureoutthecorrectanswer.
SampleInput
2
12342A4B
12430A4B
3
07323A3B
15260A0B
45670A2B
-1
SampleOutput
2134
0734
ChineseChess
BothXnbyandHekuilikeplayingChineseChess.Therearetwosides:blackandred
(inthefiguresbelow,redisthepieceswithwhitecharacters)inChineseChess.Eachsidetakemovesinturns.Oneday,theymadeacomposition(Now,it’sred'sturn):
Bytheway,eachsidecanonlymovethe”Cannon”
and
the”Pawn”
.Thecannoncanmoveinstraightlinesatany
distance(fromonecrosstoanother)ifnootherchesspiecesblock
itsway.Andthepawncanonlymoveforward,oneunitperturn.(Forthered,top-bottomisforward,andfortheblack,bottom-top).
Afterthediscussion,theyallagreethatonlywhenoneside,forexample,theblackcannonisforcedtotakeahorizonalmovewhich
makestheredcannoncangettothehemlineoftheblack,thentheredwins(Seethefollowingfigure).
So,theymakeafewrules:
Thecannoncanonlymoveforward.Ifonesidehastomovethe“cannon”toleftorright,heloses.Noticethatitdoesn'tchangesituationifacannonmovesbackward,becausetheoppositesidecanmoveitscannonforwardforthesamedistance.
Onlythepawnswhichhaven'tcrossedtherivercanmove.Andthedistancebetweeneachpairofpawns(onered,oneblack)mustexceed1.
Thewinneronlydependsonthedistancemandn(betweenthepairofcannonsinthesameverticallinecountingfromtheleftside),S1,S2,S3(betweenthepairofpawns”whichnotcrosstheriverinthesameverticallinecountingfromtheleftside).
XnbyandHekuiwanttoknow:whichsideisthewinnerwheneachofthemmovesinthebeststrategy.Tomakeitmoreinteresting,
m,n,S1,S2,S3arenotlimitedbyChineseChessboard,inotherwords,Chessboardofthisgameislargeenough.
輸入
Thereareseveraltestcases,eachcaseinasinglelinewhichcontains5integersseparatedbyablank:m,n,S1,S2,S3,0≤m,n≤1000000,1≤S1,S2,S3≤1000。Theinputterminateswhenonelinecontainsasinglenegativeinteger,whichneedn'ttobeprocessed.
輸出
Foreachtestcase,outputthewinner(RedorBlack)
樣例輸入
41221
00111
-1
樣例輸出
RedBlack
PageReplacement
Pagereplacementalgorithmswereahottopicofresearchanddebateinthe1960sand1970s.ThatmostlyendedwiththedevelopmentofsophisticatedLRUapproximationsandworkingsetalgorithms.Sincethen,somebasicassumptionsmadebythetraditionalpagereplacementalgorithmswereinvalidated,resultinginarevivalofresearch.Inparticular,thefollowingtrendsinthebehaviorofunderlyinghardwareanduser-levelsoftwarehasaffectedtheperformanceofpagereplacementalgorithms:
Sizeofprimarystoragehasincreasedbymultipleordersofmagnitude.Withseveralgigabytesofprimarymemory,algorithmsthatrequireaperiodiccheckofeachandeverymemoryframearebecominglessandlesspractical.Memoryhierarchieshavegrowntaller.ThecostofaCPUcachemissisfarmoreexpensive.Thisexacerbatesthepreviousproblem.
Localityofreferenceofusersoftwarehasweakened.Thisismostlyattributedtothespreadofobject-orientedprogrammingtechniquesthatfavorlargenumbersofsmallfunctions,useofsophisticateddatastructuresliketreesandhashtablesthattendtoresultinchaoticmemoryreferencepatterns,andtheadventofgarbagecollectionthatdrasticallychangedmemoryaccessbehaviorofapplications.
Requirementsforpagereplacementalgorithmshavechangedduetodifferencesinoperatingsystemkernelarchitectures.Inparticular,mostmodernOSkernelshaveunifiedvirtualmemoryandfilesystemcaches,requiringthepagereplacementalgorithmtoselectapagefromamongthepagesofbothuserprogramvirtualaddressspacesandcachedfiles.Thelatterpageshavespecificproperties.Forexample,theycanbelocked,orcanhavewriteorderingrequirementsimposedbyjournaling.
Moreover,asthegoalofpagereplacementistominimizetotaltimewaitingformemory,ithastotakeintoaccountmemoryrequirementsimposedbyotherkernelsub-systemsthatallocatememory.Asaresult,pagereplacementinmodernkernels(Linux,FreeBSD,andSolaris)tendstoworkatthelevelofageneralpurposekernelmemoryallocator,ratherthanatthehigherlevelofavirtualmemorysubsystem.
Therearemanypagereplacementalgorithms,oneofthemisLRU:
Theleastrecentlyusedpage(LRU)replacementalgorithm,thoughsimilarinnametoNRU(Notrecentlyused),differsinthefactthatLRUkeepstrackofpageusageoverashortperiodoftime,whileNRUjustlooksattheusageinthelastclockinterval.LRUworksontheideathatpagesthathavebeenmostheavilyusedinthepastfewinstructionsaremostlikelytobeusedheavilyinthenextfewinstructionstoo.WhileLRUcanprovidenear-optimalperformanceintheory(almostasgoodasAdaptiveReplacementCache),itisratherexpensivetoimplementinpractice.Thereareafewimplementationmethodsforthisalgorithmthattrytoreducethecostyetkeepasmuchoftheperformanceaspossible.
OneimportantadvantageofLRUalgorithmisthatitisamenabletofullstatisticalanalysis.Ithasbeenproved,forexample,thatLRUcanneverresultinmorethanN-
7012
string
0304230321201701reference
7772 2 4440 1 11
000 0 0033 3 00 page
framesinpool
11 3 3222 2 27
Foragivenreferencestring,youneedtocalculatethenumberofpagefaults.
輸入
Thefirstlinecontainsaninteger,thenumberoftestcases.Eachtestcasecontainstwolines,thefirstlineisthecapacityofthemanagementpoolm(0<m≤10000),andthelengthofreferencestringn(0<n≤100000).Thenextlinecontainsexactlynintegers,whichindicatethereferencesequenceofpageframes(pagenumberrangedfrom0ton).
輸出
Foreachtestcase,theoutputshouldcontainsthenumberofpagefaultsthatoccurred.
樣例輸入
3
35
12345
35
12123
320
70120304230321201701
樣例輸出
5
3
12
STTask
YougetaSTtask,thatis:givenastickoneendofwhoismooredontheground,youareaskedtoturnoverthestickbyholdingtheotherend.Whenitreachesthegroundagain,thetaskisfinished.Itistruethatontheprocess,thestickisalwaysonthesameplaneverticaltheground.Andonthisplane,thereislightfromuptodown,sothatwecanseeonthegroundalineofshadow.Lookatthepicture:
Inordertoexpresstheshadowpartandtheun-shadow(lightspace)part,tosimpletheproblemwejustneedtoexpressthelengththat2timesofthelengthofthestickwheretheshadowmayoccur.
Now,givetheproblem:thestickonthebeginningisontheleftofthemooredpoint,andweturnitoncertainangularspeed,usinga‘S’todenoteoneunitofthelightspaceanda‘T’foroneunitoftheshadowline.Besidethat,arealnumberisneededtotellthescalebetweentheshadowlineandthefulllinewhereshadowmaybe.
輸入
Thereisonlyonecase.TwointegersL(0<L≤25)andV(0<V≤90)isgiven.Listhelengthofthestick;Vistheangularspeedoftheturningtask,inanglepersecond
輸出
Foreverysecondduringthetask,youareaskedtotelltheshapeoftheshadowontheground.Seethesample:‘S’forthelightspaceand‘T’fortheshadow.
樣例輸入
2515
樣例輸出
TTTTTTTTTTTTTTTTTTTTTTTTTSSSSSSSSSSSSSSSSSSSSSSSSS 0.50000
STTTTTTTTTTTTTTTTTTTTTTTTSSSSSSSSSSSSSSSSSSSSSSSSS 0.48296
SSSTTTTTTTTTTTTTTTTTTTTTTSSSSSSSSSSSSSSSSSSSSSSSSS 0.43301
SSSSSSSTTTTTTTTTTTTTTTTTTSSSSSSSSSSSSSSSSSSSSSSSSS 0.35355
SSSSSSSSSSSSTTTTTTTTTTTTTSSSSSSSSSSSSSSSSSSSSSSSSS 0.25000
SSSSSSSSSSSSSSSSSSSTTTTTTSSSSSSSSSSSSSSSSSSSSSSSSS 0.12941
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 0.00000
SSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTSSSSSSSSSSSSSSSSSSS 0.12941
SSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTSSSSSSSSSSSS 0.25000
SSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTSSSSSSS 0.35355
SSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTSSS 0.43301
SSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTS 0.48296
SSSSSSSSSSSSSSSSSSSSSSSSSTTTTTTTTTTTTTTTTTTTTTTTTT 0.50000
提示
Ifthestickis3inlength,andtheshadowlineis1.49,wehavetheanswerthismoment:SSTSSS0.24833Ifthestickis3inlength,andtheshadowlineis1.51,wehavetheanswerthismoment:STTSSS0.25167Thatis,thenumberof‘T’alwaysisthenearestintegerofthelengthofshadow.
8numbersproblem
Ithinkalmosteveryacmerwillknowthe8numbersproblemwhichisaveryfamousproblem.Thegamebeginfromtheinitialstateofa3*3matrixwhichmakesupof8numbers(1-8)andablankblock(0).movetheblankblockwithitsadjacentblockuntilreachtheobjectivestate.Itisobviousthattheblankblockhasfourdirectionswhichitcanmovetowhenitisatthemiddleposition,i.e.up,down,left,right.Also,ithastwodirectionswhenitisatthecornerofthematrixandthreedirectionsatotherposintion.Formexample,theinitialstateofthematrix:
803
214
765
theobjectivestate:
123
804
765
andwegiveavalidmovingpath:
8
0
3
8
1
3
8
1
3
0
1
3
1
0
3
1
2
3
2
1
4
>2
0
4
>0
2
4
>8
2
4
>8
2
4
>8
0
4
7
6
5
7
6
5
7
6
5
7
6
5
7
6
5
7
6
5
Moreover,thepathwithleaststepsiscalledtheshortestpath.Andthe8numbersischeckwhethertherearethepathfromtheinitialstatetotheobjectivestateandifitexists,givetheshortestpath.
Andweallknowhuicpc229isnotverygoodatsearch,sohehasn'tsolvedthisproblemnow.Buthehassolvedanothereasyproblem.Theproblemisdescribedasfollow:
Giveaninitialstateofthematrix,andgiveasequenceofmoving.Foreverymoving,iftheblankblockcanmovetothedirectionasthemoving,moveit,otherwiseignorethismoving.Andwewanttoknowthefinalstateofthematrix.
輸入
Thefirstlineoftheinputisoneintegert,thenumberoftestcase.Foreachtestcase:
Threelinesrespondtotheinitialstateofthematrix,andtherewillbethreenumbersoneachofthethreelines.
Followbyanintergermcorrespondingtothenumberofmoving.
Thenextmline,everylinecontainonlyonecharacter:
U:movetheblankblockupforoneblock.D:movetheblankblockdownforoneblock.L:movetheblankblockleftforoneblock.
R:movetheblankblockrightforoneblock.
輸出
Foreachtestcaseoutputthefinalstateofthematrixforthreelinesasabove.Andtherewillbeablankspacebetweeneverytwonumbersonthesameline.Andyoushouldoutputoneblanklineaftereachtestcase.
樣例輸入
1
803
214
765
2
DR
樣例輸出
813
240
765
TheQianJinTeachingBuilding
時(shí)間限制(普通/Java):10000MS/100000MS 運(yùn)行內(nèi)存限制:65536KByte
Whenyoutrytosolvethisproblem,Ithinkthereisonlyatmostonemonthleftforourfootmen(FM2008)stayingatourAlmaMater.Ithinkthesefouryearsisthehappiestandmostimportanttimeinallmylife.IlearnedtostudyandmetsomanysincerefriendsinourschoolespeciallyinourACMteam.Itistoosimplethatjustsay“THX”toexpressmysincerethank,butImustsay“Thankyou“foryouall.IsendmyparticularthanktoDoctorWuforyouhelpandcaretomeandthewholeACMteam.Huicpc3-15,myteammateatfootmen,isthemostimportantbosomfriendinmylife.WeareclassmatesintheMathematicsandAppliedMathematics05-
1.WetookpartintheMathematicalModelingContesttogether,andparticipatedinACMContestasteammates.Wesurmountedthedifficulties,sufferedthedefeatandenjoyedthegladofsuccesstogether.Togetherwetastedthejoysandsorrowsoflife.Butitisalwaystruethatpleasanthoursflypast,anditistimetopart.Ican’thelptorunbacktothetimewhenwestudiedintheQianjingteachingbuildingforourexaminationsandlearnedtheknowledgeaboutalgorithmandprogramming.
Asweallknowthenumbersofseatsintheclassroomsarenotalwayssame.Whentheexaminationweekcomes,therewillbethesecasesthatitistoolargeforaclassbutthereisnosmallclassroomwhichisenoughforthem.Somanyseatsareleftunusedbutwecan’tuse.SoeverytimewewenttotheQianjinteachingbuildingtostudy,itisahardtimetofindafreeclassroom.Ireallylikeifth
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度鋼材行業(yè)投資分析與風(fēng)險(xiǎn)評(píng)估合同
- 2025版學(xué)校體育器材租賃與維護(hù)服務(wù)協(xié)議3篇
- 教育科技在心理健康領(lǐng)域的創(chuàng)新應(yīng)用
- 二零二五年度打字員與出版社合同:圖書編輯與排版服務(wù)協(xié)議2篇
- 社交媒體在小學(xué)數(shù)學(xué)教學(xué)中的作用與影響
- 教育信息化背景下的探究式學(xué)習(xí)法研究
- 2025年度能源管理創(chuàng)業(yè)合伙人共同投資協(xié)議4篇
- 二零二五年度成都離婚協(xié)議公證辦理材料審核及處理合同4篇
- 企業(yè)可持續(xù)發(fā)展與創(chuàng)新型組織架構(gòu)的關(guān)系
- 小學(xué)階段數(shù)學(xué)與信息技術(shù)課程的資源整合
- 2025-2030年中國MPV汽車市場全景調(diào)研及投資策略分析報(bào)告
- 二零二五年度數(shù)據(jù)存儲(chǔ)與備份外包服務(wù)協(xié)議2篇
- 2024-2025學(xué)年初中七年級(jí)上學(xué)期數(shù)學(xué)期末綜合卷(人教版)含答案
- 2023年1月浙江高考英語聽力試題及答案(含MP3+錄音原文)
- 房產(chǎn)抵押注銷申請(qǐng)表
- 【課件】第三課 蒙娜麗莎 課件高中美術(shù)湘美版美術(shù)鑒賞
- 新媒體研究方法教學(xué)ppt課件(完整版)
- 2020新版?zhèn)€人征信報(bào)告模板
- 東芝空調(diào)維修故障代碼匯總
- 工藝管道儀表流程圖(共68頁).ppt
- 五項(xiàng)管理行動(dòng)日志excel表格
評(píng)論
0/150
提交評(píng)論