Sum Product Segments - Starters 50

Why finding the L R (by which we can make L x R = Y) give wrong answer?
Here first I find out all possible L x R which can make Y, then I tried to find L’ + R’ = X which may not intersect with L and R.

Can anyone give any case where my code will give the wrong answer? Or my approach is not correct?

Solution Link : Solution: 70619730 | CodeChef

for following test case your code fails:

1 20

Your Output

2 18
1 1

Here it should have been

0 1
2 10

We need to find L1, R1 such that L1+R1=X i.e L1+R1=1
and L2 * R2 = Y i.e L2 * R2 = 20 , but your output doesn’t satisfy this condition.

Ohh thanks!!

I have read the statement wrong, I thought the order of X and Y don’t matter.

Ok got AC, by just commenting on that part where I tried to find L x R from given N.

1 Like