7th后浙大ACM总结.docx
- 文档编号:24022532
- 上传时间:2023-05-23
- 格式:DOCX
- 页数:119
- 大小:433.76KB
7th后浙大ACM总结.docx
《7th后浙大ACM总结.docx》由会员分享,可在线阅读,更多相关《7th后浙大ACM总结.docx(119页珍藏版)》请在冰豆网上搜索。
7th后浙大ACM总结
第一次ACM总结(7thACM)
ZOJProblemSet–1001A+BProblem1
ZOJProblemSet–1037Gridland2
ZOJProblemSet–1045HangOver4
ZOJProblemSet–1048FinancialManagement6
ZOJProblemSet–1049IThinkINeedaHouseboat8
ZOJProblemSet–1067ColorMeLess11
ZOJProblemSet–1073RoundandRoundWeGo14
ZOJProblemSet–1113uCalculatee17
ZOJProblemSet–1115DigitalRoots19
ZOJProblemSet–1151WordReversal21
ZOJProblemSet–1216Deck23
ZOJProblemSet-1240IBMMinusOne25
ZOJProblemSet-1241GeometryMadeSimple27
ZOJProblemSet-1251BoxofBricks30
ZOJProblemSet-1292IntegerInquiry32
ZOJProblemSet-1331PerfectCubes34
ZOJProblemSet-1337Pi36
ZOJProblemSet-1350TheDrunkJailer39
ZOJProblemSet-1382ASimpleTask41
ZOJProblemSet-1712SkewBinary43
ZOJProblemSet-1730CrazyTeaParty45
ZOJProblemSet-1760Doubles47
ZOJProblemSet-1763ASimpleQuestionofChemistry49
ZOJProblemSet-1797LeastCommonMultiple52
ZOJProblemSet-1871Steps54
ZOJProblemSet-1879JollyJumpers//又是没有代码56
ZOJProblemSet-1915AboveAverage58
ZOJProblemSet-2001AddingReversedNumbers60
ZOJProblemSet-2201NoBrainer63
ZOJProblemSet-2388BeattheSpread!
65
ZOJProblemSet-2947Abbreviation67
ZOJProblemSet-2965AccuratelySay"CocaCola"!
70
ZOJProblemSet-2969EasyTask72
ZOJProblemSet-2970Faster,Higher,Stronger74
ZOJProblemSet-2987Misspelling77
ZOJProblemSet-2988Conversions79
ZOJProblemSet–3313Clock//没有代码……82
ZOJProblemSet–3322WhoisOlder?
83
ZOJProblemSet-3323SomaliPirates85
ZOJProblemSet-3328WuXing87
ZOJProblemSet-3333GuessthePrice90
附录:
ACM常见单词表92
ZOJProblemSet–1001A+BProblem
TimeLimit:
1Second MemoryLimit:
32768KB
Calculate[计算]a+b
Input
Theinputwillconsistofaseriesofpairsofintegersaandb,separatedbyaspace,onepairofintegersperline.
Output
Foreachpairofinputintegersaandbyoushouldoutputthesumofaandbinoneline,andwithonelineofoutputforeachlineininput.
SampleInput
15
SampleOutput
6
思路:
略
代码呈现:
#include
intmain()
{
inta,b;
while(scanf("%d%d",&a,&b)!
=EOF)//无限输入直到遇见shift+F6停止
printf("%d\n",a+b);
return0;
}
代码效果:
ZOJProblemSet–1037Gridland
TimeLimit:
1Second MemoryLimit:
32768KB
Background
Foryears,computerscientistshavebeentryingtofindefficientsolutionstodifferentcomputing[计算]problems.Forsomeofthemefficientalgorithms[算法]arealreadyavailable,thesearethe"easy"problemslikesorting[整理;排序;分类拣选],evaluatingapolynomial[多项式]orfindingtheshortestpathinagraph.Forthe"hard"onesonlyexponential-timealgorithms[指数时间算法]areknown.Thetraveling-salesmanproblembelongstothislattergroup.GivenasetofNtownsandroadsbetweenthesetowns,theproblemistocomputetheshortestpathallowingasalesmantovisiteachofthetownsonceandonlyonceandreturntothestartingpoint.
Problem
ThepresidentofGridlandhashiredyoutodesignaprogramthatcalculatesthelengthoftheshortesttraveling-salesmantourforthetownsinthecountry.InGridland,thereisonetownateachofthepointsofarectangulargrid[直角坐标网].RoadsrunfromeverytowninthedirectionsNorth,Northwest,West,Southwest,South,Southeast,East,andNortheast,providedthatthereisaneighboringtowninthatdirection.ThedistancebetweenneighboringtownsindirectionsNorth-SouthorEast-Westis1unit.ThelengthoftheroadsismeasuredbytheEuclideandistance[欧几里得距离].Forexample,Figure7shows2*3-Gridland,i.e.,arectangulargridofdimensions[规模,大小]2by3.In2*3-Gridland,theshortesttourhaslength6.
Figure7:
Atraveling-salesmantourin2*3-Gridland.
Input
Thefirstlinecontainsthenumberofscenarios[剧情(情况)].
Foreachscenario,thegriddimensionsmandnwillbegivenastwointegernumbersinasingleline,separatedbyasingleblank,satisfying1 Output Theoutputforeachscenariobeginswithalinecontaining"Scenario#i: ",whereiisthenumberofthescenariostartingat1.Inthenextline,printthelengthoftheshortesttraveling-salesmantourroundedtotwodecimaldigits.Theoutputforeveryscenarioendswithablankline. SampleInput 2 22 23 SampleOutput Scenario#1: 4.00 Scenario#2: 6.00 思路: 如果城镇数是偶数,即分布的行和列至少有一个是偶数的时候,我们可以一个个走,正好最后一次回到起始城镇,即m*n;如果是奇数,就是说分布的行和列都是奇数,那么我们倒数第二次到的城镇和起点城镇之间相距斜线,即m*n-1+根号2。 代码呈现: #include #include intmain(void) { intk,i=1; floatm,n; scanf("%d",&k);//循环执行的次数 while(k--) { scanf("%f%f",&m,&n); if((int)m%2! =0&&(int)n%2! =0) printf("Scenario#%d: \n%.2f\n\n",i,m*n-1+sqrt (2)); else printf("Scenario#%d: \n%.2f\n\n",i,n*m); } return0; } 代码效果: ZOJProblemSet–1045HangOver TimeLimit: 1Second MemoryLimit: 32768KB Howfarcanyoumakeastackofcardsoverhangatable? Ifyouhaveonecard,youcancreateamaximumoverhangofhalfacardlength.(We'reassuming[假设]thatthecardsmustbeperpendiculartothetable.)Withtwocardsyoucanmakethetopcardoverhangthebottomonebyhalfacardlength,andthebottomoneoverhangthetablebyathirdofacardlength,foratotalmaximumoverhangof1/2+1/3=5/6cardlengths.Ingeneralyoucanmakencardsoverhangby1/2+1/3+1/4+...+1/(n+1)cardlengths,wherethetopcardoverhangsthesecondby1/2,thesecondoverhangsthethirdby1/3,thethirdoverhangsthefourthby1/4,etc.,andthebottomcardoverhangsthetableby1/(n+1).Thisisillustrated[有插图的]inthefigurebelow. Theinputconsistsofoneormoretestcases,followedbyalinecontainingthenumber0.00thatsignalstheendoftheinput.Eachtestcaseisasinglelinecontainingapositivefloating-pointnumbercwhosevalueisatleast0.01andatmost5.20;cwillcontainexactlythreedigits. Foreachtestcase,outputtheminimumnumberofcardsnecessarytoachieveanoverhangofatleastccardlengths.Usetheexactoutputformatshownintheexamples. Exampleinput: 1.00 3.71 0.04 5.19 0.00 Exampleoutput: 3card(s) 61card(s) 1card(s) 273card(s) 思路: 题意: 输入的小数在0.01-5.20之间,输出满足1/2+1/3+……+1/(n+1)稍大于小数的n的值 1.无限输入小数 2.判断该小数是否在0.01-5.20之间 3.对1/2+1/3+……+1/(n+1)进行累加,同时判断该式子是否大于小数,是则输出n。 不是则继续循环直至是 代码呈现: #include intmain() { floata; doubles; intn; while(scanf("%f",&a)! =EOF&&a! =0.00) { s=0.00; n=1; if(a>=0.01&&a<=5.20) { for(;a>s;n++) s+=1.0/(n+1); printf("%dcard(s)\n",n-1); } } return0; } 代码效果: ZOJProblemSet–1048FinancialManagement TimeLimit: 1Second MemoryLimit: 32768KB Larrygraduatedthisyearandfinallyhasajob.He'smakingalotofmoney,butsomehowneverseemstohaveenough.Larryhasdecidedthatheneedstograbholdof[控制、抓住]hisfinancialportfolioandsolvehisfinancingproblems.Thefirststepistofigureoutwhat'sbeengoingonwithhismoney.Larryhashisbankaccountstatementsandwantstoseehowmuchmoneyhehas.HelpLarrybywritingaprogramtotakehisclosingbalancefromeachofthepasttwelvemonthsandcalculatehisaverageaccountbalance[账户余额]. InputFormat: Theinputwillbetwelvelines.Eachlinewillcontaintheclosingbalance[终期余额]ofhisbankaccount[银行存款]foraparticularmonth.Eachnumberwillbepositiveanddisplayedtothepenny.Nodollarsignwillbeincluded. OutputFormat: Theoutputwillbeasinglenumber,theaverage(mean)oftheclosingbalancesforthetwelvemonths.Itwillberoundedtothenearestpenny,precededimmediatelybyadollarsign,andfollowedbytheend-of-line.Therewillbenootherspacesorcharactersintheoutput. SampleInput: 100.00 489.12 12454.12 1234.10 823.05 109.20 5.27 1542.25 839.18 83.99 1295.01 1.75 SampleOutput: $1581.42 思路: 求12个浮点型实数的和,然后求平均输出 注: 输出$时的格式是printf("$%.2f",s); 代码呈现: #include voidmain() { inti; floata,s; s=0.0; for(i=0;i<12;i++) { scanf("%f",&a); s=s+a; } s=s/12; printf("$%.2f\n",s); } 代码效果: ZOJProblemSet–1049IThinkINeedaHouseboat TimeLimit: 1Second MemoryLimit: 32768KB FredMapperisconsideringpurchasing[购买,获得]somelandinLouisianatobuildhishouseon.Intheprocessofinvestigating[调查;审查]theland,helearnedthatthestateofLouisianaisactuallyshrinking[退缩]by50squaremileseachyear,duetoerosion[侵蚀,腐蚀]causedbytheMississippiRiver.SinceFredishopingtoliveinthishousetherestofhislife,heneedstoknowifhislandisgoingtobelosttoerosion. Afterdoingmoreresearch,Fredhaslearnedthatthelandthatisbeinglostformsasemicircle[半圆,半圆形].Thissemicircleispartofacirclecenteredat(0,0),withthelinethatbisects[二等分]thecirclebeingtheXaxis[X轴].LocationsbelowtheXaxisareinthewater.Thesemicirclehasanareaof0atthebeginningofyear1.(SemicircleillustratedintheFigure.) InputFormat: Thefirstlineofinputwillbeapositiveintegerindicatinghowmanydatasetswillbeincluded(N). EachofthenextNlineswillcontaintheXandYCartesiancoordinates[笛卡儿坐标]ofthelandFredisconsidering.Thesewillbefloatingpointnumbersmeasuredinmiles.TheYcoordinatewillbenon-negative.(0,0)willnotbegiven. OutputFormat: Foreachdataset,asinglelineofoutputshouldappear.Thislineshouldtaketheformof: ��PropertyN: ThispropertywillbeginerodinginyearZ.�� WhereNisthedataset(countingfrom1),andZisthefirstyear(startfrom1)thispropertywillbewithinthesemicircleATTHEENDOFYEARZ.Zmustbeaninteger. Afterthelastdataset,thisshouldprintout��ENDOFOUTPUT.�
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- th 浙大 ACM 总结