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

Обсуждение задачи 1518. Джедайский ребус 3

Help~~How to solve it?
Послано tob 17 дек 2006 18:43
Can anybody help?
Re: Help~~How to solve it?
Послано svr 27 фев 2007 23:15
Easy solution without optimization efforts.
Use Matrix A=
[0   1  0  0  0  0]
[0   0  1  0  0  0]
[0   0  0  0  1  0]
[0   0  0  0  0  1]
[c1 c2 c3 c4 c5 c6]
Answer=[[A^(X-N)]*K][N]
Thus we must calculate pow A^(X-N)
Use famous O(lg) pow in groop of matrix
__int64 in inner calculations and int (rez)%Y as result
Re: Help~~How to solve it?
Послано Denis Koshman 18 июл 2008 17:33
My such solution ran for 2.9 seconds with 3 for TL. So it's still not enogh for stable solution.

I had to differentiate between M^2 and M*A matrix multiplications (the latter can be implemeted via int, +, - and >=), then it ran for 1.5 sec :)
Re: Help~~How to solve it?
Послано Chmel_Tolstiy 18 июл 2008 18:43
My such realisation works in 0.609.
Re: Help~~How to solve it?
Послано Harkonnen 17 авг 2022 11:13
This time even without optimizations on +- for fast modulus, and not using fact that matrix is sparse in those cases (so multiplication can be done at O(N^2)) - it's 0.078 sec. With these optimizations - 0.046 sec.

Edited by author 17.08.2022 11:56