You are on page 1of 3

2/8/2016

ChefandStrangeOperations|CodeChef
Login

PRACTICE

COMPETE

Signup

DISCUSS

COMMUNITY

HELP

ABOUT

HomeCompeteFebruaryChallenge2016ChefandStrangeOperations

ChefandStrangeOperations

ALLSUBMISSIONS

Problemcode:STROPR
Tweet

https://www.codechef.com/FEB16/problems/STROPR

1/3

2/8/2016

ChefandStrangeOperations|CodeChef
Read problems statements in Mandarin Chinese, Russian and Vietnamese as
well.

SUCCESSFULSUBMISSIONS

Chef has an array A consisting of N integers (1based indexing). He asks you to perform the following
operationMtimes:

fori=2toN:

Ai=Ai+Ai1
Yourtaskistofindthexthelementofthearray(i.e.,Ax )afterperformingtheaboveoperationMtimes.As
theanswercouldbelarge,pleaseoutputitmodulo109 +7.

Input
ThefirstlineofinputcontainsanintegerTdenotingthenumberoftestcases.
ThefirstlineofeachtestcasecontainsthreespaceseparatedintegersN,x,andMdenotingthe
sizeofthearray,indexoftheelementyouneedtofind,andtheamountoftimesyouneedtorepeat
operation before finding the element, respectively. The second line contains N spaceseparated
integersA1 ,A2 ,,AN.

Output
Foreachtestcase,outputasinglelinecontainingoneinteger:Ax modulo109 +7.

Constraints
1T10
1xN105
1M1018
1Ai1018

Subtasks
Subtask1(8points):
1xmin{2,N}
Subtask2(24points):
1N*M106
Subtask3(68points):Noadditionalconstraints

Example
Input:
2
323
123
333
123
Output:
5
15

Explanation
ValuesinthearrayA:
Beforetheoperations:[1,2,3]
Afterthefirstoperation:[1,3,6]
Afterthesecondoperation:[1,4,10]
Afterthethirdoperation:[1,5,15]
Sinceinputfilecanbefairlylarge(about8MB),it'srecommendedtousefastI/O(forexample,inC++,
usescanf/printfinsteadofcin/cout).
Author:

antoniuk1

Tester:

iscsi

DateAdded:

23012015

TimeLimit:

2sec

SourceLimit: 50000Bytes

Languages:

ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14,
CS2,D,ERL,FORT,FS,GO,HASK,ICK,ICON,JAVA,JS,LISPclisp,LISPsbcl,LUA,NEM,
NICE,NODEJS,PASfpc,PASgpc,PERL,PERL6,PHP,PIKE,PRLG,PYPY,PYTH,PYTH
3.1.2,RUBY,SCALA,SCMchicken,SCMguile,SCMqobi,ST,TCL,TEXT,WSPC

SUBMIT

Comments

CodeChefisanoncommercialcompetitiveprogrammingcommunity

https://www.codechef.com/FEB16/problems/STROPR

2/3

2/8/2016

ChefandStrangeOperations|CodeChef

AboutCodeChef AboutDirecti CEO'sCorner CProgramming ProgrammingLanguages ContactUs


2009DirectiGroup.AllRightsReserved.CodeChefusesSPOJbySphereResearchLabs
Inordertoreportcopyrightviolationsofanykind,sendinanemailtocopyright@codechef.com

Thetimenowis:05:52:14PM
YourIP:14.99.82.107

CodeChefAPlatformforAspiringProgrammers
CodeChefwascreatedasaplatformtohelpprogrammersmakeitbigintheworldofalgorithms,computerprogrammingandprogrammingcontests.AtCodeChefweworkhardto
revivethegeekinyoubyhostingaprogrammingcontestatthestartofthemonthandanothersmallerprogrammingchallengeinthemiddleofthemonth.Wealsoaimtohave
trainingsessionsanddiscussionsrelatedtoalgorithms,binarysearch,technicalitieslikearraysizeandthelikes.Apartfromprovidingaplatformforprogrammingcompetitions,
CodeChefalsohasvariousalgorithmtutorialsandforumdiscussionstohelpthosewhoarenewtotheworldofcomputerprogramming.

PracticeSectionAPlacetohoneyour'ComputerProgrammingSkills'
Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+
programminglanguages.Preparingforcodingcontestswereneverthismuchfun!Receivepoints,andmoveupthroughtheCodeChefranks.Useourpracticesectiontobetterprepare
yourselfforthemultipleprogrammingchallengesthattakeplacethroughoutthemonthonCodeChef.

CompeteMonthlyProgrammingContestsandCookoffs
Hereiswhereyoucanshowoffyourcomputerprogrammingskills.Takepartinour10daylongmonthlycodingcontestandtheshorterformatCookoffcodingcontest.Putyourself
upforrecognitionandwingreatprizes.OurprogrammingcontestshaveprizesworthuptoINR20,000(forIndianCommunity),$700(forGlobalCommunity)andlotsmoreCodeChef
goodiesupforgrabs.

ProgrammingTools

PracticeProblems

Initiatives

OnlineIDE

Easy

GoforGold

UpcomingCodingContests

Medium

CodeChefforSchools

ContestHosting

Hard

CampusChapters

ProblemSetting

Challenge

CodeChefTutorials

Peer

CodeChefWiki

School
FAQ's

https://www.codechef.com/FEB16/problems/STROPR

3/3

You might also like