Tower

시간 제한2초메모리 제한512 MB

요약
1만 들어 있는 탑에서 시작해 매 단계마다 현재 종이들의 연속 구간 합을 위에 쌓을 때, 각 목표 q에 대해 q를 만드는 최소 길이의 구간 선택 순서를 출력한다.
난이도

보통10점 중 7점

유형
수학, 그리디, 구현, 재귀
정답자
아직 제출이 없습니다

문제

Farmhand Jernej gets bored in the evenings, thus he invented a simple game. He wants to build a tower from numbers on pieces of paper. He starts with a piece of paper and writes 1 on it.

Jernej can write another number on a piece of paper and place it on top of the tower. The new value on the top of the tower must be a valid sum of numbers on consecutive papers comprising the tower. Let's say there are currently n pieces of paper comprising the tower. He makes a sum of numbers in the tower within arbitrary positions [l, u], where 1 ≤ l ≤ u ≤ n and puts the sum on top.

Jernej wants to produce T towers with desired numbers on top. Help him find out the required steps. He also asks you to minimize the number of those steps.

입력

In the first line of input, you will be given a positive integer T (number of different towers Jernej wants to produce).

In each of the next T lines, there will be one positive integer q , the value Jernej wants to produce at the end. All games are independent.

출력

For each integer q:

  • print one line with number s (0 ≤ s ≤ 1000) - required steps to produce the desired value.
  • In the next s lines, there should be 2 space-separated positive integers l and u, range bounds to produce the desired value.

제한

  • 1 ≤ T ≤ 1000
  • 1 ≤ q ≤ 1018

예제1

  1. 예제 1

    입력
    3
    2
    3
    7
    
    예상 출력
    2
    1 1
    1 2
    3
    1 1
    2 2
    1 3
    4
    1 1
    1 2
    2 3
    1 4