Grove

시간 제한3초메모리 제한2048 MB

요약
한 변의 길이가 n인 정사각형 안에 정수 좌표의 점을 최대한 많이 놓되, 반지름 r인 원판이 정사각형 안에 들어가고 서로 경계에서만 만나야 한다.
난이도

보통10점 중 7점

유형
기하, 완전 탐색, 그리디, 구현
정답자
아직 제출이 없습니다

문제

You want to plant trees in a square lawn of size n×nn \times n whose corners have Cartesian coordinates (0,0)(0, 0), (n,0)(n, 0), (0,n)(0, n), and (n,n)(n, n). Trees can only be planted at locations with integer coordinates. Every tree will grow roots within a disk of radius rr centered at the location where the tree was planted; such disks must be fully contained in the lawn (possibly touching the boundary of the lawn) and can only intersect each other on their boundaries.

Find a configuration that maximizes the number of trees.

입력

The first and only line contains an integer nn (1≤n≤201 ≤ n ≤ 20) and a real number rr (0<r≤n/20 < r ≤ n/2) — the length of the sides of the lawn, and the radius of the disks where each tree will grow roots. The real number rr is given in decimal notation with at least 11 and at most 33 digits after the decimal point.

출력

In the first line, print the maximum number mm of trees that can be planted.

In the next mm lines, print a configuration that maximizes the number of trees. Specifically, in the (i+1)(i + 1)-th line, print two integers xx and yy — the coordinates of the location where the ii-th tree should be planted. You can print the trees in any order.

If there are multiple solutions, print any of them.

예제2

  1. 예제 1

    입력
    6 1.241
    
    예상 출력
    2
    4 2
    2 4
    
  2. 예제 2

    입력
    9 2.0
    
    예상 출력
    4
    2 2
    7 2
    2 6
    6 6