资源描述:
《东华大学9月20号acm网上预赛题目》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、AnotherDoorRepairingProblemMaybeyouhavealreadysolvedtheDoorRepairingProblemforYY,whoistheofficeroftheaccommodationbuildingB37,inafamousuniversitycalledFamousUniversity.Maybeyouhavenot,butitdoesnotmatterbecausethenewtermiscoming.SoherecomestheAnotherDoorRep
2、airingProblem!AsisdescribedinDoorRepairingProblem,manystudentsliveinB37.Thebuildingisold,sosometimesacarelessstudentsuchasLMYmayopenthedoorofthebuildingtoovigorously,andbreakitasaresult.However,whenastudentopensthedoorandfindsitalreadybroken,hewillreportit
3、totheheadmaster,andconsequentlyYYwillbepunished…Moreprecisely,thedoorisfineatthebeginningoftheterm.ThetermhasalengthofTterm.Duringtheterm,thedoorwillbeopenedmanytimes,whichcanberegardedasaPoissonprocess,i.e.,inanyperiodoflengthT,theprobabilitythatthedoorwi
4、llbeopenedktimesis,whereλisapositiverealconstant.Notethatforanynon-negativerealT,Whenthedoorisfineandisopenedbysomestudent,theprobabilitythathecarelesslybreaksthedoorisp.(0
5、punishedcostalot.YYhasthoughtformanydaystryingtomakeabeststrategywhentorepairthedoor,sothathisexpectedexpensecanbeminimized.Hefailed,soheisgoingtotrythesimplestwaysinstead.GiventhelengthofthetermTterm,theconstantλ,theprobabilityp,andthequestiontypeQ,youare
6、tosolvetheAnotherDoorRepairingProblem:WhenQ=1,telltheexpectednumberoftimesYYhastorepairthedoor,ifhealwaysrepairsitimmediatelyafteritisbroken.WhenQ=2,telltheexpectednumberoftimesYYwillbepunished,ifheneverrepairsthedoor.InputInputcontainsmultipletestcases.At
7、estcaseconsistsofasinglelinecontainingfournumbers.ThefirstisanintegerQ,whereQ=1orQ=2holds,indicatingthetypeoftheproblemthatyoushouldsolve.Threepositiverealnumbersλ,Ttermandpfollow.Therealnumbersmaybegiveninfixed-pointorscientificenotations.Allrealnumbersca
8、nbestoreinadoubledatatypeofC/C++,withasufficientlysmallerrorrate.Seethesampleinputfordetails.Inputendswithalinecontainingfourspace-separated0s.OutputForeachtestcase,outputonelinecontainingyoursolutiontothespe