아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Simple Polygon

메모리 제한1024 MB

요약
정수 N과 A가 주어질 때, 꼭짓점 N개를 가진 단순 다각형의 넓이 두 배가 정확히 A가 되도록 정수 좌표를 구성하거나 불가능함을 판정한다.
난이도

보통10점 중 7점

유형
기하, 구현, 수학
정답자
아직 제출이 없습니다

문제

You are given two integers, the number of vertices NN and area AA. You need to construct a simple polygon of NN vertices such that the area of the polygon is exactly A2\frac{A}{2}, and all the vertices have non-negative integer coordinates with value up to 10910^9.

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, TT. TT lines follow. The first line of each test case contains two integers, NN denoting the number of vertices and AA, denoting double the required area of the polygon.

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is IMPOSSIBLE if it is not possible to construct a polygon with the given requirements and POSSIBLE otherwise.

If you output POSSIBLE, output NN more lines with 22 integers each. The ii-th line should contain two integers X_iX\_i and Y_iY\_i which denote the coordinates of the ii-th vertex. For each ii, the coordinates should satisfy the 0≤X_i,Y_i≤1090 \le X\_i,Y\_i ≤ 10^9 constraints. Vertices of the polygon should be listed in consecutive order (vertex_ivertex\_i should be adjacent to vertex_i−1vertex\_{i-1} and vertex_i+1vertex\_{i+1} in the polygon).

If there are multiple possible solutions, you can output any of them.

제한

  • 1≤T≤1001 \le T \le 100.
  • 1≤A≤1091 \le A \le 10^9.

예제1

  1. 예제 1

    입력
    2
    4 36
    5 2
    
    예상 출력
    Case #1: POSSIBLE
    2 5
    6 5
    8 2
    0 2
    Case #2: IMPOSSIBLE