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

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

ETA

시간 제한1초메모리 제한1024 MB

요약
목표 분수 a/b가 주어질 때 정점 1까지의 평균 최단 거리가 a/b인 연결 무방향 그래프를 만들거나, 불가능하면 불가능하다고 출력한다.
난이도

보통10점 중 6점

유형
그래프, 수학, 그리디
정답자
아직 제출이 없습니다

문제

You want to design a level for a computer game. The level can be described as a connected undirected graph with vertices numbered from 11 to nn. In the game, the player's character is dropped at one of the nn vertices uniformly at random and their goal is to reach the exit located at vertex 11 as quickly as possible. Traversing an edge takes exactly 11 second.

Figure E.1: Illustration of Sample Output 3, a level where the average optimal time to reach vertex 11 is 74\frac{7}{4}.

The difficulty of the level is determined by the average optimal time to reach the exit. Given a target value for this average optimal time, construct a level so that this target value is reached. See Figure E.1 for an example.

입력

The input consists of:

  • One line with two coprime integers aa and bb (1≤a,b≤10001 \le a,b \le 1000) separated by a '/', giving the desired average optimal time to reach the exit as the fraction ab\frac{a}{b}.

출력

If no connected graph with the average optimal time ab\frac{a}{b} to reach vertex 11 exists, output "impossible". Otherwise, output one such graph in the following format:

  • Two integers nn and mm (1≤n,m≤1061 \le n, m \le 10^6), the number of vertices and the number of edges.
  • mm pairs of integers uu and vv (1≤u,v≤n1 \le u,v \le n), indicating an edge between vertices uu and vv.

The graph may include self loops and parallel edges. You are given that if there exists a valid graph, then there also exists one with 1≤n,m≤1061 \le n, m \le 10^6.

If there are multiple valid solutions, you may output any one of them.

예제3

  1. 예제 1

    입력
    1/2
    
    예상 출력
    2 1
    1 2
    
  2. 예제 2

    입력
    1/3
    
    예상 출력
    impossible
    
  3. 예제 3

    입력
    7/4
    
    예상 출력
    8 12
    1 2
    1 3
    2 3
    2 4
    3 5
    3 6
    4 5
    5 6
    4 7
    5 7
    4 8
    6 8