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

Обсуждение задачи 1495. Раз-два, раз-два 2

This problem easy to solve with DP(+)
Послано Aram Shatakhtsyan 7 янв 2008 17:39
Just use DP, which is fast enough (AC 0.187s),
and works without using long arithmetics in O(30*n).
Only remember simple math theorems about mod, i. e.
(a+b) mod c = ((a mod c) + (b mod c)) mod c
(a-b) mod c = ((a mod c) - (b mod c)) mod c
(a*b) mod c = ((a mod c) * (b mod c)) mod c
Re: This problem easy to solve with DP(+)
Послано Vedernikoff Sergey 8 янв 2008 12:09
My brute-force solution got AC in 0.062s
Re: This problem easy to solve with DP(+)
Послано Aram Shatakhtsyan 8 янв 2008 12:44
Brute force without big numbers?
I think that the most easy solution is that,
where long arithmetics not used.
Re: This problem easy to solve with DP(+)
Послано AlMag 11 авг 2008 23:06
DP here? How?
Re: This problem easy to solve with DP(+)
Послано AlMag 11 авг 2008 23:29
Oh, i've got...
Let's see...
Re: This problem easy to solve with DP(+)
Послано AlMag 12 авг 2008 00:58
No, i have too slow AC :( 1.531
Can anyone explain DP?
Re: This problem easy to solve with DP(+)
Послано SkorKNURE 20 июн 2009 20:08
simple O(N) solution, 0.030s

You are completely right about using:
> (a*b) mod c = ((a mod c) * (b mod c)) mod c

Uses very facile DP technique like used[i] = true/false ;-)
Re: This problem easy to solve with DP(+)
Послано Partisan 23 июн 2009 21:22
You can achieve O(N) using bfs.

Edited by author 23.06.2009 21:23
Re: This problem easy to solve with DP(+)
Послано Zayakin Andrey[PermSU] 14 апр 2010 20:18
AlMag писал(a) 11 августа 2008 23:06
DP here? How?
it`s knapsack problem
Re: This problem easy to solve with DP(+)
Послано AleZan 8 дек 2011 15:33
please can anyone tell me how to solve this in briefly by bfs or dp......
Re: This problem easy to solve with DP(+)
Послано ACSpeed - Nguyen Khac Tung 12 дек 2011 20:36
I try DP but TLE #15, can send me your solution to my email : tungnk1993@gmail.com Tks
Re: This problem easy to solve with DP(+)
Послано Ximera 11 мар 2013 00:13
I think it's nearer to bfs then DP