2546: 好*,好暴力!!!(集训队)

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:43 解决:10

题目描述

给出接下来的序列,用操作符‘-’(减号) 或者 ‘+’(加号) 代替 '?' 使满足给出的式子

?1?2?3...?n = k

比如给出k = 12

-1 + 2 + 3 + 4 + 5 + 6 -7 = 12;

所以最小的n = 7

输入

The first line is the number of test cases,followed by a blank line;

Each test case of input contains an integer k (0 <= abs(k) <= 1,000,000,000) ;

Each test case will be separated by a single line;

输出

For each test case,your program should print the minimal possible n (n >= 1) to obtaink with above formula;

每两个输出之间要有空行

样例输入 复制

1

12

样例输出 复制

7