Spoiler

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

요약
각 x에 대해 재귀가 m 이후로 다항식을 따르고 m번째 값이 x가 되는 k, f1, m을 찾는다.
난이도

어려움10점 중 8점

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

문제

For a positive integer kk and a positive integer f_1f\_1, a sequence ff is recursively generated according to the following formula for n≥2n \geq 2: f_n=kn+⌈f_n−1n⌉⋅nf\_n = k n + \left \lceil \frac{f\_{n-1}}{n} \right \rceil \cdot n 

For example, if k=4k = 4 and f_1=23f\_1 = 23:

 f_1=23 f_2=4⋅2+24=32 f_3=4⋅3+33=45 f_4=4⋅4+48=64 f_5=4⋅5+65=85 f_6=4⋅6+90=114 f_7=4⋅7+119=147 \begin{array}{lllrrrr} f\_1 & & & & & = & 23 \\\ f\_2 & = & 4 \cdot 2 & + & 24 & = & 32 \\\ f\_3 & = & 4 \cdot 3 & + & 33 & = & 45 \\\ f\_4 & = & 4 \cdot 4 & + & 48 & = & 64 \\\ f\_5 & = & 4 \cdot 5 & + & 65 & = & 85 \\\ f\_6 & = & 4 \cdot 6 & + & 90 & = & 114 \\\ f\_7 & = & 4 \cdot 7 & + & 119 & = & 147 \\\ \end{array}  

For such a sequence, an index m≥2m \geq 2 is called the starting index of interpolation if there exists a polynomial P(n)P(n) such that P(n)=f_nP(n) = f\_n for every n≥mn \geq m, but P(m−1)≠f_m−1P(m-1) \neq f\_{m-1}. In the example above, 55 is the starting index of interpolation: for every index greater than 44, f_n=P(n)=2n2+7nf\_n = P(n) = 2 n^2 + 7 n, but f_4=64≠P(4)=60f\_4 = 64 \neq P(4) = 60.

You are given an integer xx. Find any pair of parameters f_1f\_1 and kk and an index mm satisfying the following conditions, or report there are none:

  •  1≤f_1≤10101 \leq f\_1 \leq 10^{10}, 1≤k≤1051 \leq k \leq 10^5, 2≤m≤10182 \leq m \leq 10^{18};
  •  mm is the starting index of interpolation for the sequence generated with these parameters;
  •  f_m=xf\_m = x.

The condition with inequalities is important. In particular, if, for some input, the only triplets (f_1,k,m)(f\_1, k, m) which satisfy the last two conditions don't meet the first one, then you should report there is no solution.

입력

Each test contains one or more test cases. The first line contains the number of test cases tt (1≤t≤1001 \le t \le 100).

The only line of each test case contains an integer xx (2≤x≤1018)2 \le x \le 10^{18}). There is at most one test case with \(x > 10^9\).

출력

For each test case, if there is no answer, print -1.

Otherwise, output a line with three integers: f_1f\_1, kk, mm (1≤f_1≤10101 \leq f\_1 \leq 10^{10}, 1≤k≤1051 \leq k \leq 10^5, 2≤m≤10182 \leq m \leq 10^{18}). If there are multiple solutions, print any one of them.

힌트

Warning! For the third test case, "2 2 2" is not a right answer because in that case P(1)=f_1P(1) = f\_1, thus 22 is not the starting index of interpolation.

예제1

  1. 예제 1

    입력
    4
    85
    7
    6
    637275712755506
    
    예상 출력
    23 4 5
    -1
    1 2 2
    -1