시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 11912 4630 3813 37.507%

문제

오른쪽 그림과 같이 삼각형이 나선 모양으로 놓여져 있다. 첫 삼각형은 정삼각형으로 변의 길이는 1이다. 그 다음에는 다음과 같은 과정으로 정삼각형을 계속 추가한다. 나선에서 가장 긴 변의 길이를 k라 했을 때, 그 변에 길이가 k인 정삼각형을 추가한다.

파도반 수열 P(N)은 나선에 있는 정삼각형의 변의 길이이다. P(1)부터 P(10)까지 첫 10개 숫자는 1, 1, 1, 2, 2, 3, 4, 5, 7, 9이다.

N이 주어졌을 때, P(N)을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, N이 주어진다. (1 ≤ N ≤ 100)

출력

각 테스트 케이스 마다 P(N)을 출력한다.

예제 입력 1

2
6
12

예제 출력 1

3
16

힌트

W3sicHJvYmxlbV9pZCI6Ijk0NjEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzMGNcdWIzYzRcdWJjMTggXHVjMjE4XHVjNWY0IiwiZGVzY3JpcHRpb24iOiI8cD48aW1nIGFsdD1cIlwiIHNyYz1cIlwvdXBsb2FkXC9pbWFnZXNcL3BhbmRvdmFuLnBuZ1wiIHN0eWxlPVwiZmxvYXQ6cmlnaHQ7IGhlaWdodDoxODJweDsgd2lkdGg6Mjg5cHhcIiBcLz5cdWM2MjRcdWI5NzhcdWNhYmQgXHVhZGY4XHViOWJjXHVhY2ZjIFx1YWMxOVx1Yzc3NCBcdWMwYmNcdWFjMDFcdWQ2MTVcdWM3NzQgXHViMDk4XHVjMTIwIFx1YmFhOFx1YzU5MVx1YzczY1x1Yjg1YyBcdWIxOTNcdWM1ZWNcdWM4MzggXHVjNzg4XHViMmU0LiBcdWNjYWIgXHVjMGJjXHVhYzAxXHVkNjE1XHVjNzQwIFx1YzgxNVx1YzBiY1x1YWMwMVx1ZDYxNVx1YzczY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