HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Dynamic programming & Greedy > problem:


50687 - Pascal Triangle - 2

Guest
• Review clarifications (2)

Section problems

• 50979 - Minimum access cost for BST
• 51062 - Fish Pond II
• 51010 - Max Sequential Sum
• 51072 - Castle on chessboard
• 51075 - Shortest Path for Bishop
• 50688 - Epoka Furgon
• 50524 - Elevator
• 50536 - Epoka Furgon Shpk
• 50687 - Pascal Triangle - 2
• 50689 - The biggest building block
• 50686 - The Container
• 50682 - Hotel Durres
• 50930 - Tom and Jerry
• 50526 - Gold Market
• 50488 - Connecting Wires
• 50681 - Center of a Series
• 50561 - Lucky tickets

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.
Question by Ibrahim Mesecan.

Pascal Triangle - 2

In Pascal Triangle, except the first and last elements of each row, any element is equal to the sum of the above two elements.
pascal(n,r) = pascal(n-1,r-1) + pascal(n-1,r)

Question:
Write a program that calculates nth row rth element in Pascal Triangle.

Input specification
You will be given 2 numbers (n,r) where 1 ≤ n ≤ 60 and 0 ≤ r ≤ n

Output specification
Show one number: nth row rth element of the Pascal Triangle.

Sample Input I   
  5 0
Sample Input II   
  8 5
Sample Output I   
  1
Sample Output II   
  56


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

www.contester.ru