Simple Polygon
메모리 제한1024 MB
정수 N과 A가 주어질 때, 꼭짓점 N개를 가진 단순 다각형의 넓이 두 배가 정확히 A가 되도록 정수 좌표를 구성하거나 불가능함을 판정한다.
문제
You are given two integers, the number of vertices and area . You need to construct a simple polygon of vertices such that the area of the polygon is exactly , and all the vertices have non-negative integer coordinates with value up to .
A simple polygon is one that:
- Defines a closed area.
- Does not have self-intersections, even at a single point.
- No two consecutive edges form a straight angle.
입력
The first line of the input gives the number of test cases, . lines follow. The first line of each test case contains two integers, denoting the number of vertices and , denoting double the required area of the polygon.
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is IMPOSSIBLE if it is not possible to construct a polygon with the given requirements and POSSIBLE otherwise.
If you output POSSIBLE, output more lines with integers each. The -th line should contain two integers and which denote the coordinates of the -th vertex. For each , the coordinates should satisfy the constraints. Vertices of the polygon should be listed in consecutive order ( should be adjacent to and in the polygon).
If there are multiple possible solutions, you can output any of them.
제한
- .
- .