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

Aram Shatakhtsyan This problem easy to solve with DP(+) [11] // Problem 1495. One-two, One-two 2 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
Vedernikoff Sergey Re: This problem easy to solve with DP(+) [8] // Problem 1495. One-two, One-two 2 8 Jan 2008 12:09
My brute-force solution got AC in 0.062s
Aram Shatakhtsyan Re: This problem easy to solve with DP(+) [7] // Problem 1495. One-two, One-two 2 8 Jan 2008 12:44
Brute force without big numbers?
I think that the most easy solution is that,
where long arithmetics not used.
DP here? How?
Oh, i've got...
Let's see...
No, i have too slow AC :( 1.531
Can anyone explain DP?
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 ;-)
Zayakin Andrey[PermSU] Re: This problem easy to solve with DP(+) [2] // Problem 1495. One-two, One-two 2 14 Apr 2010 20:18
AlMag wrote 11 August 2008 23:06
DP here? How?
it`s knapsack problem
please can anyone tell me how to solve this in briefly by bfs or dp......
ACSpeed - Nguyen Khac Tung Re: This problem easy to solve with DP(+) // Problem 1495. One-two, One-two 2 12 Dec 2011 20:36
I try DP but TLE #15, can send me your solution to my email : tungnk1993@gmail.com Tks
You can achieve O(N) using bfs.

Edited by author 23.06.2009 21:23
I think it's nearer to bfs then DP