杭电部分题目.docx
- 文档编号:6548352
- 上传时间:2023-01-07
- 格式:DOCX
- 页数:42
- 大小:60.36KB
杭电部分题目.docx
《杭电部分题目.docx》由会员分享,可在线阅读,更多相关《杭电部分题目.docx(42页珍藏版)》请在冰豆网上搜索。
杭电部分题目
杭电1015
Safecracker
TimeLimit:
2000/1000MS(Java/Others) MemoryLimit:
65536/32768K(Java/Others)
TotalSubmission(s):
4768 AcceptedSubmission(s):
2386
ProblemDescription
===Optechbriefing,2002/11/0206:
42CST===
"TheitemislockedinaKleinsafebehindapaintinginthesecond-floorlibrary.Kleinsafesareextremelyrare;mostofthem,alongwithKleinandhisfactory,weredestroyedinWorldWarII.FortunatelyoldBrumbaughfromresearchknewKlein'ssecretsandwrotethemdownbeforehedied.AKleinsafehastwodistinguishingfeatures:
acombinationlockthatuseslettersinsteadofnumbers,andanengravedquotationonthedoor.AKleinquotationalwayscontainsbetweenfiveandtwelvedistinctuppercaseletters,usuallyatthebeginningofsentences,andmentionsoneormorenumbers.Fiveoftheuppercaselettersformthecombinationthatopensthesafe.Bycombiningthedigitsfromallthenumbersintheappropriatewayyougetanumerictarget.(Thedetailsofconstructingthetargetnumberareclassified.)Tofindthecombinationyoumustselectfivelettersv,w,x,y,andzthatsatisfythefollowingequation,whereeachletterisreplacedbyitsordinalpositioninthealphabet(A=1,B=2,...,Z=26).Thecombinationisthenvwxyz.Ifthereismorethanonesolutionthenthecombinationistheonethatislexicographicallygreatest,i.e.,theonethatwouldappearlastinadictionary."
v-w^2+x^3-y^4+z^5=target
"Forexample,giventarget1andlettersetABCDEFGHIJKL,onepossiblesolutionisFIECB,since6-9^2+5^3-3^4+2^5=1.Thereareactuallyseveralsolutionsinthiscase,andthecombinationturnsouttobeLKEBA.Kleinthoughtitwassafetoencodethecombinationwithintheengraving,becauseitcouldtakemonthsofefforttotryallthepossibilitiesevenifyouknewthesecret.Butofcoursecomputersdidn'texistthen."
===Optechdirective,computerdivision,2002/11/0212:
30CST===
"DevelopaprogramtofindKleincombinationsinpreparationforfielddeployment.Usestandardtestmethodologyasperdepartmentalregulations.Inputconsistsofoneormorelinescontainingapositiveintegertargetlessthantwelvemillion,aspace,thenatleastfiveandatmosttwelvedistinctuppercaseletters.ThelastlinewillcontainatargetofzeroandthelettersEND;thissignalstheendoftheinput.ForeachlineoutputtheKleincombination,breaktieswithlexicographicorder,or'nosolution'ifthereisnocorrectcombination.Usetheexactformatshownbelow."
SampleInput
1ABCDEFGHIJKL
11700519ZAYEXIWOVU
3072997SOUGHT
1234567THEQUICKFROG
0END
SampleOutput
LKEBA
YOXUZ
GHOST
nosolution
#include
#include
#include
longget_taget(inti,intj,intk,intl,intm){
longtaget=0;
taget=i-pow((float)j,2)+pow((float)k,3)-pow((float)l,4)+pow((float)m,5);
returntaget;
}
voidsort(intarray[],intsize)
{
inti,j,temp;
for(i=0;i { for(j=0;j if(array[j] { temp=array[j]; array[j]=array[j+1]; array[j+1]=temp; } } } intmain(){ inti,j,k,l,m,len,f; longdata,taget; charstr[12]; intkey[12]={0}; while(scanf("%ld%s",&data,&str)){ f=0; if(0==data&&'E'==str[0]&&'N'==str[1]&&'D'==str[2]) break; len=strlen(str); if(len<5||len>12) break; for(i=0;i key[i]=str[i]-'A'+1; } sort(key,len); for(i=0;i for(j=0;j if(i==j) continue; for(k=0;k if(k==i||k==j) continue; for(l=0;l if(l==k||l==i||l==j) continue; for(m=0;m if(m==l||m==k||m==j||l==i) continue; taget=get_taget(key[i],key[j],key[k],key[l],key[m]); if(taget==data){ f=1; key[i]=key[i]+64; key[j]=key[j]+64; key[k]=key[k]+64; key[l]=key[l]+64; key[m]=key[m]+64; printf("%c%c%c%c%c\n",key[i],key[j],key[k],key[l],key[m]); } } } } } } if(f==0) printf("nosolution\n"); } return0; } 杭电1017: AMathematicalCuriosity TimeLimit: 2000/1000MS(Java/Others) MemoryLimit: 65536/32768K(Java/Others) TotalSubmission(s): 16821 AcceptedSubmission(s): 5238 ProblemDescription
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 部分 题目
![提示](https://static.bdocx.com/images/bang_tan.gif)