HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Recursion > problem:


50376 - Sequences

Guest
• Discussion of problem (1)

Section problems

• 51081 - Fish Pond I
• 50935 - Max Discount
• 50724 - Number of Circles
• 50729 - Max number in 2D array
• 50928 - War Of Battleships
• 50577 - Perfect Numbers and Perfec...
• 50725 - Fibonacci Series
• 50370 - Number of rectangles in a ...
• 50376 - Sequences
• 50421 - Repairing road segments
• 50389 - Reverse an Array
• 50727 - Fibonacci Numbers
• 50726 - Pascal Triangle - 1
• 50475 - Voice advertising
• 50721 - Palindrome

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Prepared by Ilir Capuni. Difficulty Beta

Finding the n-th element of a sequence

Question:
A sequence of integers is defined using the following equations
  A2n = An
  A2n+1 = An + An+1
Find the nth element of the sequence without the need to generate all previous elements.

Input specification
You will be given two positive integers n and A1 where 1 ≤ n ≤ 10000 and 1 ≤ A1 ≤ 1000.

Output specification
Show just one integer number:the nth element of the sequence.

Sample Input I   
  11 1
Sample Input II   
  9 3
Sample Output I   
  5
Sample Output II   
  12



Для отправки решений необходимо выполнить вход.

www.contester.ru