[Solution] Sum Product Segments CodeChef Solution
Problem
A segment is a range of non-negative integers , denoted where .
Chef has a set consisting of all segments such that either or .
For example, if and , then Chef's set is .
Given the integers and , can you help Chef find two non-intersecting segments from his set ? If it is not possible to find two such non-intersecting segments, print . If there are multiple possible answers, you may output any of them.
Note: Two segments are said to be non-intersecting if they have no number in common. For example,
- and are non-intersecting
- and are intersecting since they have and in common.
- and are intersecting since they have in common.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists of a single line containing two space separated integers and .
Output Format
- If there are non-intersecting segments, then output two lines:
- In the first line, output two space-separated integers denoting the first segment.
- In the second line, output two space-separated integers denoting the second segment.
- If there are no such segments, print on a single line.
No comments:
Post a Comment