Hello ,
I tried to solve this problem using subset sum algorithm and precalculation for all numbers which satisfy the given condition, But i got alot of TLE.
is there any fast subset sum algorithm better than O(n^2) ??
This is the problem :http://www.ahmed-aly.com/p.jsp?ID=172
And this is my code : Edit after AC :D
Thanks
The DP table is very sparse, try to solve it using recursion.
What does sparse means ??
And this is my recursive solution : http://ideone.com/7gtEMT
Can you explain, what is the meaning of two sequential question marks?
Nothing,, Im just used to write some characters two or three times.
inb4 stupid habit :D
simple dp solution with O(SUM*N) will work i think
Edit: solved it, with top-down dp and some small optimisations (sieved all ps numbers (it seems those which are less that 1101 are not so many, used fast i/o + one opt in the main loop).
Does your code looks like something like this : http://ideone.com/9642qf
still getting TLE !!
this is mine spoiler
ok your code gets AC,, but i don't understand why did you consider the numbers in array ps as the only used Psycho numbers ??
because while i was coding i printed all such numbers in the given interval and saw only these
Ok I did that to and I got much more numbers than those
Please see my method for testing Those numbers and tell me what differs between mine and yours