跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2800. Square

    ID: 2806 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 2 上传者: 标签>数学基础难度共享题库Codeforces英文题面题目来源题面语言

Square

题目描述

B. Square
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There is a square painted on a piece of paper, the square's side equals n meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the square's perimeter in the clockwise direction (first upwards, then to the right, then downwards, then to the left and so on). Every time he walks (n+1) meters, he draws a cross (see picture for clarifications).

John Doe stops only when the lower left corner of the square has two crosses. How many crosses will John draw?

The figure shows the order in which John draws crosses for a square with side 4. The lower left square has two crosses. Overall John paints 17 crosses.
Input

The first line contains integer t (1≤t≤104) − the number of test cases.

The second line contains t space-separated integers ni (1≤ni≤109) − the sides of the square for each test sample.

Output

For each test sample print on a single line the answer to it, that is, the number of crosses John will draw as he will move along the square of the corresponding size. Print the answers to the samples in the order in which the samples are given in the input.

Please do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples
Input
3
4 8 100
Output
17
33
401

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 2470 题。保留原作者与原赛事署名。