编程介的小学生
2017-11-24 16:18Herbert
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条回答
为你推荐
- matplotlib 绘图代码如何在 PyCharm 中有提示或者自动补全
- python
- 1个回答
- 是否可以在single.php中更改HTML?
- wordpress
- php
- 2个回答
- 我想更改多维数组的键[关闭]
- php
- 1个回答
- 无法解析php中的json数组
- json
- php
- 1个回答
- 大家看下Herbert如何才能通过AC,感觉有点思路不清楚了
- 游戏
- each
- square
- 1个回答
换一换