Basically I reduce the 4's with 6's following this IDEA:
Let's say we can group the 4's into N groups ( N is even )
where in each group we have three 4's.
Now each group I substitute with 2 elements of value 6.
So for each i = 1 to N, we do n[6] +=2;
Then I reduce the 5's with 6's following this IDEA:
Let's say we can group the 5's into N groups ( N is even )
where in each group we have six 5's.
Now each group I substitute with 5 elements of value 6.
So for each i = 1 to N, we do n[6] +=5
Apparently this is not logically OK. ?!
Or ?
I want a proof or a counter example
Moderator: Board moderators
Accepted P.E.
Yes, right, I have it
Accepted P.E.
now.
I found the problem with my reasoning.
Actually the code I posted here and the reasoning behind it
was completely wrong.
Thanks, little joey!
Accepted P.E.
now.
I found the problem with my reasoning.
Actually the code I posted here and the reasoning behind it
was completely wrong.
Thanks, little joey!
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
Tricks to solve it fast are very cool. but Optimized DP is good enough to get accepted, not very fast around .3 second.
Running time : O(sum)
a[] is the input
t[] is the boolean function.
for (i = 1; i <= 6; i++)
if (a)
for (j = sum; j >= 0; j--)
if (t[j])
for (k = 1; k <= a; k++)
if (j + i * k > sum || t[j + i*k]) break;
else t[j + i * k] = 1;
Running time : O(sum)
a[] is the input
t[] is the boolean function.
for (i = 1; i <= 6; i++)
if (a)
for (j = sum; j >= 0; j--)
if (t[j])
for (k = 1; k <= a; k++)
if (j + i * k > sum || t[j + i*k]) break;
else t[j + i * k] = 1;