ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1313. К вопросу о спорте

HINT
Послано Varun Sharma 6 май 2009 10:26
Hi,

Well it took me a while to figure out as to how to approach this problem but as it turned out it is pretty straightforward. I divided the problem into two parts. First I printed out the elements up until the middle diagonal. And then the elements after that.

Here is the format of the numbers for 4 X 4 array

0,0  0,1  0,2  0,3
1,0  1,1  1,2  1,3
2,0  2,1  2,2  2,3
3,0  3,1  3,2  3,3

We can see a pattern here. First print the element 0,0.

Then -> 1,0 to 0,1    (i = 1 to i = 0 and j = 0 to j = 1)
Then -> 2,0 to 0,2    (i = 2 to i = 0 and j = 0 to j = 2)
Then -> 3,0 to 0,3    (i = 3 to i = 0 and j = 0 to j = 3)

So, basically as we are heading towards the main diagonal, we are increasing the value of i and at the same time running j from 0 to i.

Implementing this will get you the first 10 out of 16. For the rest of them, we have the same pattern again but this time its reverse

Then -> 3,1 to 1,3    (i = 3 to i = 1 and j = 1 to j = 3)
Then -> 3,2 to 2,3    (i = 3 to i = 2 and j = 2 to j = 3)
Then the last element 3,3

So, this just requires some clever manipulation of the for loops or while loops.
Re: HINT
Послано Lifeisbeautiful 23 дек 2020 12:53
Thank you!
Re: HINT
Послано Igor Mallea 7 июн 2021 10:23
Thank you very much!!!