CF1459B.Move and Turn

普及-

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A robot is standing at the origin of the infinite two-dimensional plane. Each second the robot moves exactly 11 meter in one of the four cardinal directions: north, south, west, and east. For the first step the robot can choose any of the four directions, but then at the end of every second it has to turn 90 degrees left or right with respect to the direction it just moved in. For example, if the robot has just moved north or south, the next step it takes has to be either west or east, and vice versa.

The robot makes exactly nn steps from its starting position according to the rules above. How many different points can the robot arrive to at the end? The final orientation of the robot can be ignored.

一个机器人位于无限二维平面的原点处。每一秒,机器人恰好向四个基本方向(北、南、西、东)之一移动 11 米。第一步时,机器人可任选四个方向之一;但从第二步起,每秒结束时,机器人必须相对于其上一步的移动方向向左或向右转 90∘90^\circ。例如,若机器人上一步向北或向南移动,则下一步只能向西或向东移动;反之亦然。

机器人严格按照上述规则从起点出发,恰好移动 nn 步。问:机器人最终可能到达的不同位置(即坐标点)有多少个?机器人的最终朝向无需考虑。

输入格式

The only line contains a single integer nn (1≤n≤10001 \leq n \leq 1000) — the number of steps the robot makes.

唯一的一行包含一个整数 nn(1≤n≤10001 \leq n \leq 1000)——机器人行走的步数。

输出格式

Print a single integer — the number of different possible locations after exactly nn steps.

输出一个整数——恰好经过 nn 步后所有可能的不同位置的数量。

输入输出样例

  • 输入#1

    1

    输出#1

    4
  • 输入#2

    2

    输出#2

    4
  • 输入#3

    3

    输出#3

    12

说明/提示

In the first sample case, the robot will end up 1 meter north, south, west, or east depending on its initial direction.

In the second sample case, the robot will always end up 2\sqrt{2} meters north-west, north-east, south-west, or south-east.

在第一个样例中,机器人最终将位于起点正北、正南、正西或正东方向 1 米处,具体取决于其初始朝向。

在第二个样例中,机器人最终将总是位于起点正西北、正东北、正西南或正东南方向 2\sqrt{2} 米处。

输入解题思路,AI测评打分。不知道怎么写?

首页