HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Array and Matrices > problem:


155. 50726 - Pascal Triangle - 1

Guest
• Discussion of problem (2)

Volume problems

• 110. 50359 - Mode of a Series
• 120. 50331 - Number of Numbers o...
• 120. 50329 - Draw Matrix-1
• 125. 50538 - Sum of kth Diagonal
• 140. 50599 - Sum of Squared Error ...
• 15-SprPrE1-80. 50741 - DNA Distance
• 151. 50557 - nth Power of m (Long...
• 155. 50334 - What is the class aver...
• 155. 50726 - Pascal Triangle - 1
• 160. 50301 - Fractions to Decimals
• 165. 50360 - National Elections
• 170. 50319 - Toll Plazas
• 180. 50755- Top N Donors - 1
• 185. 50784 - Top Growing Company
• 190. 50734 - Product Info (In Srt)
• 200. 50290 - Minimax Sum
• 210. 50361 - Align Two Lists

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. Difficulty Beta

Pascal Triangle - 1

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 0 ≤ n ≤ 30 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