Actually This is a piece of question ,i am struggling in that part so i want help . 1. so the problem is you have two equations — v=x*v1+y*v2
— x*s1+y*s2<=s
you have the values of v1,v2,s1,s2,s all are fit in 32 bit integer .you have to maximize the value of v ?? Constraints : s1>=1,s2>=1,v1>=1,v2>=1,v>=1,s>=1,x>=0,y>=0 and s1,s2,v1,v2,x,y,v,s all are positive integer.
You don't give enough information.
.
Or in a similar fashion:
More readable, isn't it?
And a side note: I don't know how others think, but I think you should improve on your interpunction (sorry to say, but the writing style like yours usually discourages me from answering).
Now that you have updated the post with additional data, we can start thinking.
Let's say the number of tests given is small. In such applications we call feasible solutions the solutions which satisfy all the constraints (in our case, s1x + s2y ≤ s, x ≥ 0 and y ≥ 0). When we draw it on the plane, we will easily see that the feasible solutions are the lattice points inside or on the boundary of the triangle with vertices (0, 0), and . We have to find the feasible solution for which the value v1x + v2y is the biggest.
We can use the following trick:
if , then for each feasible solution (x, y) the inequality follows. Then we can take each possible nonnegative integer x-coordinate (), take the highest point with this coordinate (when we look at the objective function, it'll become obvious why we shouldn't care about lower points) and check if it isn't the best solution. In this case we have time.
if , we do exactly the same, but with y-coordinates and get time.
if nothing above follows, then s1, s2 are reasonably small (not bigger than ). Let's say that (x, y) is an optimal feasible solution. Now consider two solutions: (x - s2, y + s1) and (x + s2, y - s1).
In all four cases, we have total running time (if I'm correct).