Why this is not working for this problem?
https://codeforces.com/problemset/problem/189/A
Why this is not working for this problem?
hello @cbcao263
in question it is mentioned that after cutting length of obtained stick should be either a or b or c. right?
but in ur code it is calculating for other length as well.
for example.
if n-> 7
and a= 3,b=10 ,c=15
then ur is also including this case as a valid answer ( 3,3,1 ) .
but it is invalid partition right.
approach.
let say after cutting , x are the number of a length stick , y are the numberr of b length stick and z are the number of c length stick.
then we need to maximize x+y+z
such that ax + by + c*z=n.
now use loop -> iterate for x,y,z and calulate maximum