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

Разделы > Поиск > задача:


50538 - Sum of kth Diagonal

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

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

• 51057 - Number of students
• 51046 - The biggest number
• 50535 - Image Compression
• 50450 - Last Appereance of a Number
• 50457 - The Number of Winners
• 50453 - The Cubic Difference
• 50451 - Processing Cost
• 50459 - The Biggest Digit
• 50538 - Sum of kth Diagonal
• 50465 - How many students have p...
• 50378 - Sum of the given digits
• 50470 - Close Pairs - Revised
• 50784 - Top Growing Company
• 50458 - Weekly Report
• 50478 - Letter Grades
• 50791 - Mine field
• 50867 - Average of the Best Grades

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

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

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

Sum of kth Diagonal

Question: Diagonal of a matrix starts from upper left corner and goes to the lower right corner. You are given an nXn square matrix. Find the sum of kth diagonal. For example, the third diagonal starts from the third row first element (4). And then, every element is connected to its lower right neigbour (13 and then 4) until it reaches to the border of the square.

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

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

 Sample Input   
  5 6
  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   
  30


Explanation:   6+7+7+10=30


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

www.contester.ru