2 shunfurh shunfurh 于 2017.11.25 00:18 提问

Herbert

Problem Description
Herbert is a game in which you control a robot on an infinite two-dimensional grid. There are three commands available to you:

s: Go one square forward in the current direction.

l: Turn ninety degrees counterclockwise.

r: Turn ninety degrees clockwise.
After playing this game for a while, you wonder how many squares you can reach within a certain number of moves. Write a program to calculate the answer to this question.

Input
On the first line an integer t (1 <= t <= 100): the number of test cases. Then for each test case:

One line with an integer n (0 <= n <= 1 000 000 000): the maximum number of moves.

Output
For each test case:

One line with the number of reachable squares.

Sample Input
4
0
1
2
3

Sample Output
1
2
5
11

2个回答

caozhy
caozhy   Ds   Rxr 2018.04.23 23:32
已采纳
swchlz811
swchlz811   2018.02.15 01:51

Herbert is a game in which you control a robot on an infinite two-dimensional grid. There are three commands available to you:
s: Go one square forward in the current direction.

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!