Special-Sequence
Practice
0 (0 votes)
Easy
Problem
92% Success 519 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Everyone of us knows that sahil is very good in maths, so this time Prince give him a problem of Math.The problem is that there is a special sequence whose first and second term is given and sahil have to find the $$N th$$ term of the sequence.

Special sequence have a property that the value of any term is average of its next and previous term.

Since sahil is busy in gym so he asked you to solve this problem.

Note: Since output can be very large so you have to print the answer by taking modulus with 1000000007.

Input Format:

First line contain the three integer $$A$$, $$B$$  and $$N$$ denoting the first and second term and $$N$$ represent that you have to find the $$N$$th term.

Output Format:

Output will contain the number denoting the $$N$$th term.

Constraints:

1\(\le\)$$N$$\(\le\)108

-109\(\le \)$$A$$,$$B$$\(\le\)109

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
26 votes
Tags:
Data StructuresBasic MathAlgorithmsMath BasicMath
Points:20
31 votes
Tags:
MathematicsOpenApprovedEasyMathamatics
Points:20
Tags:
Binary SearchMath BasicMath