ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Арифметика > задача:


50398 - Sum of kth Anti-diagonal

Гость
• Вопросы к жюри (1)

Задачи раздела

• 50388 - Number of Armstrong Num...
• 50363 - Class GPA Average
• 50390 - Total Salary Paid
• 50392 - How much space
• 50394 - Water Bills
• 50651 - Largest power of two
• 50297 - Divisible By Five
• 50332 - Variance of a series
• 50398 - Sum of kth Anti-diagonal
• 50400 - nth Row rth Element of a Table
• 50330 - Find the average of n numbers
• 50401 - Sum of Odd Numbers
• 50369 - Base Conversion
• 50407 - Missing Number
• 50336 - Buying Carpets
• 50338 - Convert Into Decimal
• 50404 - Sum of Self Powers

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Prepared by Ibrahim Mesecan.

Sum of kth Anti-diagonal

Question: Antidiagonal of a matrix starts from the lower left corner and goes to the upper right corner. You are given an nXn square matrix. Find the sum of kth anti-diagonal. The third anti-diagonal starts from the third row first element (6). And then, every element is connected to its upper right neigbour (first 9 and then 4).

Input specification
You will be given two integer numbers (n and k) at the beginning where 1 ≤ n ≤ 100 and 1 ≤ k ≤ n. Then, in the following n lines, you will be given n integers, which are between 0 and 1000.

Output specification
Show just one number: the sum of kth diagonal.

 Sample Input   
  5 4
  7 6 4 1 5
  5 9 7 8 7
  6 7 8 7 5
  8 8 0 4 10
  7 5 0 2 0
 Sample Output   
  23


Explanation: 8+7+7+1=23


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

www.contester.ru