Two-wheelers and four-wheelers
A parking lot has V vehicles with W wheels in total. Every vehicle is a two-wheeler or a four-wheeler. Print the number of two-wheelers and four-wheelers. If no such split is possible, print INVALID.
Reported in: TCS NQT (Sep 2023) (memory-based)
Input
One line: V and W.
Output
Two numbers (two-wheelers, four-wheelers), or INVALID.
Constraints
0 ≤ V, W ≤ 10^9.
Example 1
Input:
200 540
Output:
130 70Example 2
Input:
3 5
Output:
INVALIDHint: Four-wheelers = (W − 2V) / 2. It must be a whole number between 0 and V.