ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1495. One-two, One-two 2

This problem easy to solve with DP(+)
Posted by Aram Shatakhtsyan 7 Jan 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(+)
Posted by Vedernikoff Sergey 8 Jan 2008 12:09
My brute-force solution got AC in 0.062s
Re: This problem easy to solve with DP(+)
Posted by Aram Shatakhtsyan 8 Jan 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(+)
Posted by AlMag 11 Aug 2008 23:06
DP here? How?
Re: This problem easy to solve with DP(+)
Posted by AlMag 11 Aug 2008 23:29
Oh, i've got...
Let's see...
Re: This problem easy to solve with DP(+)
Posted by AlMag 12 Aug 2008 00:58
No, i have too slow AC :( 1.531
Can anyone explain DP?
Re: This problem easy to solve with DP(+)
Posted by SkorKNURE 20 Jun 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(+)
Posted by Partisan 23 Jun 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(+)
Posted by Zayakin Andrey[PermSU] 14 Apr 2010 20:18
AlMag wrote 11 August 2008 23:06
DP here? How?
it`s knapsack problem
Re: This problem easy to solve with DP(+)
Posted by AleZan 8 Dec 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(+)
Posted by ACSpeed - Nguyen Khac Tung 12 Dec 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(+)
Posted by Ximera 11 Mar 2013 00:13
I think it's nearer to bfs then DP