Input
TheinputwillconsistofasetofpairsofvaluesforRandn.TheRvaluewilloccupycolumns1through6,andthenvaluewillbeincolumns8and9.
Output
TheoutputwillconsistofonelineforeachlineofinputgivingtheexactvalueofR^n.Leadingzerosshouldbesuppressedintheoutput.Insignificanttrailingzerosmustnotbeprinted.Don'tprintthedecimalpointiftheresultisaninteger.
SampleInput
95.12312
0.432120
5.123415
6.75929
98.99910
1.010012
SampleOutput
548815*********830194541.899025343415715973535967221869852721
.00000005148554641076956121994511276767154838481760200726351203835429763013462401
43992025569.928573701266488041146654993318703707511666295476720493953024
29448126.764121021618164430206909037173276672
90429072743629540498.107596019456651774561044010001
1.126825*********720661201
Hint
Ifyoudon'tknowhowtodeterminewheatherencountedtheendofinput:
s isastringand n isaninteger
C++
while(cin>>s>>n)
{
...
}
c
while(scanf("%s%d",s,&n)==2)//toseeifthescanfreadinasmanyitemsasyouwant
/*while(scanf(%s%d",s,&n)!
=EOF)//thisalsowork*/
{
...
}
1002(17%)
487-3279
TimeLimit:
2000MS
MemoryLimit:
65536K
TotalSubmissions:
166172
Accepted:
28392
Description
Businessesliketohavememorabletelephonenumbers.Onewaytomakeatelephonenumbermemorableistohaveitspellamemorablewordorphrase.Forexample,youcancalltheUniversityofWaterloobydialingthememorableTUT-GLOP.Sometimesonlypartofthenumberisusedtospellaword.WhenyougetbacktoyourhoteltonightyoucanorderapizzafromGino'sbydialing310-GINO.Anotherwaytomakeatelephonenumbermemorableistogroupthedigitsinamemorableway.YoucouldorderyourpizzafromPizzaHutbycallingtheir``threetens''number3-10-10-10.
Thestandardformofatelephonenumberissevendecimaldigitswithahyphenbetweenthethirdandfourthdigits(e.g.888-1200).Thekeypadofaphonesuppliesthemappingofletterstonumbers,asfollows:
A,B,andCmapto2
D,E,andFmapto3
G,H,andImapto4
J,K,andLmapto5
M,N,andOmapto6
P,R,andSmapto7
T,U,andVmapto8
W,X,andYmapto9
ThereisnomappingforQorZ.Hyphensarenotdialed,andcanbeaddedandremovedasnecessary.ThestandardformofTUT-GLOPis888-4567,thestandardformof310-GINOis310-4466,andthestandardformof3-10-10-10is310-1010.
Twotelephonenumbersareequivalentiftheyhavethesamestandardform.(Theydialthesamenumber.)
Yourcompanyiscompilingadirectoryoftelephonenumbersfromlocalbusinesses.Aspartofthequalitycontrolprocessyouwanttocheckthatnotwo(ormore)businessesinthedirectoryhavethesametelephonenumber.
Input
Theinputwillconsistofonecase.Thefirstlineoftheinputspecifiesthenumberoftelephonenumbersinthedirectory(upto100,000)asapositiveintegeraloneontheline.Theremaininglineslistthetelephonenumbersinthedirectory,witheachnumberaloneonaline.Eachtelephonenumberconsistsofastringcomposedofdecimaldigits,uppercaseletters(excludingQandZ)andhyphens.Exactlysevenofthecharactersinthestringwillbedigitsorletters.
Output
Generatealineofoutputforeachtelephonenumberthatappearsmorethanonceinanyform.Thelineshouldgivethetelephonenumberinstandardform,followedbyaspace,followedbythenumberoftimesthetelephonenumberappearsinthedirectory.Arrangetheoutputlinesbytelephonenumberinascendinglexicographicalorder.Iftherearenoduplicatesintheinputprinttheline:
Noduplicates.
SampleInput
12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279
SampleOutput
310-10102
487-32794
888-45673
1006(30%)
Biorhythms
TimeLimit:
1000MS
MemoryLimit:
10000K
TotalSubmissions:
81827
Accepted:
24704
Description
Somepeoplebelievethattherearethreecyclesinaperson'slifethatstartthedayheorsheisborn.Thesethreecyclesarethephysical,emotional,andintellectualcycles,andtheyhaveperiodsoflengths23,28,and33days,respectively.Thereisonepeakineachperiodofacycle.Atthepeakofacycle,apersonperformsathisorherbestinthecorrespondingfield(physical,emotionalormental).Forexample,ifitisthementalcurve,thoughtprocesseswillbesharperandconcentrationwillbeeasier.
Sincethethreecycleshavedifferentperiods,thepeaksofthethreecyclesgenerallyoccuratdifferenttimes.Wewouldliketodeterminewhenatriplepeakoccurs(thepeaksofallthreecyclesoccurinthesameday)foranyperson.Foreachcycle,youwillbegiventhenumberofdaysfromthebeginningofthecurrentyearatwhichoneofitspeaks(notnecessarilythefirst)occurs.Youwillalsobegivenadateexpressedasthenumberofdaysfromthebeginningofthecurrentyear.Youtaskistodeterminethenumberofdaysfromthegivendatetothenexttriplepeak.Thegivendateisnotcounted.Forexample,ifthegivendateis10andthenexttriplepeakoccursonday12,theansweris2,not3.Ifatriplepeakoccursonthegivendate,youshouldgivethenumberofdaystothenextoccurrenceofatriplepeak.
Input
Youwillbegivenanumberofcases.Theinputforeachcaseconsistsofonelineoffourintegersp,e,i,andd.Thevaluesp,e,andiarethenumberofdaysfromthebeginningofthecurrentyearatwhichthephysical,emotional,andintellectualcyclespeak,respectively.Thevaluedisthegivendateandmaybesmallerthananyofp,e,ori.Allvaluesarenon-negativeandatmost365,andyoumayassumethatatriplepeakwilloccurwithin21252daysofthegivendate.Theendofinputisindicatedbyalineinwhichp=e=i=d=-1.
Output
Foreachtestcase,printthecasenumberfollowedbyamessageindicatingthenumberofdaystothenexttriplepeak,intheform:
Case1:
thenexttriplepeakoccursin1234days.
Usethepluralform``days''eveniftheansweris1.
SampleInput
0000
000100
52034325
4567
28310223320
20330120340
-1-1-1-1
SampleOutput
Case1:
thenexttriplepeakoccursin21252days.
Case2:
thenexttriplepeakoccursin21152days.
Case3:
thenexttriplepeakoccursin19575days.
Case4:
thenexttriplepeakoccursin16994days.
Case5:
thenexttriplepeakoccursin8910days.
Case6:
thenexttriplepeakoccursin10789days.
1009(21%)
EdgeDetection
TimeLimit:
1000MS
MemoryLimit:
10000K
TotalSubmissions:
11467
Accepted:
2445
Description
IONUSatelliteImaging,Inc.recordsandstoresverylargeimagesusingrunlengthencoding.Youaretowriteaprogramthatreadsacompressedimage,findstheedgesintheimage,asdescribedbelow,andoutputsanothercompressedimageofthedetectededges.
Asimpleedgedetectionalgorithmsetsanoutputpixel'svaluetobethemaximumabsolutevalueofthedifferencesbetweenitandallitssurroundingpixelsintheinputimage.Considertheinputimagebelow:
Theupperleftpixelintheoutputimageisthemaximumofthevalues|15-15|,|15-100|,and|15-100|,whichis85.Thepixelinthe4throw,2ndcolumniscomputedasthemaximumof|175-100|,|175-100|,|175-100|,|175-175|,|175-25|,|175-175|,|175-175|,and|175-25|,whichis150.
Imagescontain2to1,000,000,000(109)pixels.Allimagesareencodedusingrunlengthencoding(RLE).Thisisasequenceofpairs,containingpixelvalue(0-255)andrunlength(1-109).Inputimageshaveatmost1,000ofthesepairs.Successivepairshavedifferentpixelvalues.Alllinesinanimagecontainthesamenumberofpixels.
Input
Inputconsistsofinformationforoneormoreimages.Eachimagestartswiththewidth,inpixels,ofeachimageline.ThisisfollowedbytheRLEpairs,onepairperline.Alinewith00indicatestheendofthedataforthatimage.Animagewidthof0indicatestherearenomoreimagestoprocess.Thefirstimageintheexampleinputencodesthe5x7inputimageabove.
Output
Outputisaseriesofedge-detectedimages,inthesameformatastheinputimages,exceptthattheremaybemorethan1,000RLEpairs.
SampleInput
7
154
10015
252
1752
255
1752
255
00
10
35500000000
200500000000
00
3
2551
101
2552
101
2552
101
2551
00
0
SampleOutput
7
855
02
855
7510
1502
753
02
1502
04
00
10
0499999990
16520
0499999990
00
3
2459
00
0
Hint
Abruteforcesolutionthatattemptstocomputeanoutputvalueforeveryindividualpixelwilllikelyfailduetospaceortimeconstraints.
1007(39%)
DNASorting
TimeLimit:
1000MS
MemoryLimit:
10000K
TotalSubmissions:
57392
Accepted:
22516
Description
Onemeasureof``unsortedness''inasequenceisthenumberofpairsofentriesthatareoutoforderwithrespecttoeachother.Forinstance,inthelettersequence``DAABEC'',thismeasureis5,sinceDisgreaterthanfourletterstoitsrightandEisgreaterthanonelettertoitsright.Thismeasureiscalledthenumberofinversionsinthesequence.Thesequence``AACEDGG''hasonlyoneinversion(EandD)---itisnearlysorte