Move and Turn

B. Move and Turn

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.

Input

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

Output

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

Examples

input

Copy

1

output

Copy

4

input

Copy

2

output

Copy

4

input

Copy

3

output

Copy

12

Note

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–√2 meters north-west, north-east, south-west, or south-east.

题目类型:结论规律题

解题思路:打表

分奇偶!

n = 1, cnt = 4          列上的点数 1 2 1

n = 3, cnt = 12                           2 3 2 3 2

n = 5 , cnt = 24                          3 4 3 4 3 4 3

n = 7 , cnt = 40                          4 6 4 6 4 6 4 6 4

……         较小数为1 2 3 4 -》(n+1)/2 * 较小数个数2 3 4 5-》(n/2+2)

……         较大数为2 3 4 6 -》(n/2 + 2) *较大数个数1 2 3 4 -》(n+)/2

n = 2 , cnt = 4;

n = 4 , cnt = 9

n = 6 , cnt = 16

……容易知道2 2         3 3           4 4      -》(n/2+1)^2

AC代码:

#include <bits/stdc++.h>
#define rep(x, a, b) for(int x = a; x <= b; x++)
#define pre(x, a, b) for(int x = b; x >= a; x--)
#define ll long long
#define endl '\n'
#define PII pair<int, int> 
using namespace std;
const int N = 1e3+10;
int n;
void solve()
{
    cin>>n;
    if(n % 2)
    {
        ll ans =((n+ 1)/2 )*(n / 2  + 2) + ((n+1)/2 *(n/2  + 2));
        cout<<ans<<endl;
    }else cout<<(n / 2 + 1)* (n / 2 + 1)<<endl;
}
int main()
{
   int t = 1;
   bool is = false;
   if(is) cin>>t;
   //getchar();
   while(t -- )
   {
       solve();
   }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WIDE bandgap devices, such as silicon carbide (SiC) metal–oxide–semiconductor field-effect transis- tors (MOSFETs) present superior performance compared to their silicon counterparts [1]. Their lower ON-state resistance and faster switching capability attract lots of interest in high-power- density applications [2]. Faster switching speed enables lower switching loss and higher switching frequency, which is benefi- cial to high-efficiency and high power density. However, severe electromagnetic interference (EMI) and transient overvoltage issues caused by fast switching speed jeopardize the power quality and reliability of converters [3], [4]. Therefore, there is a tradeoff between efficiency and reliability in the choice of switching speed. An optimized design should ensure theoperation within both safe-operation-area and EMI limits, and switching loss should be as small as possible. A prediction method of switching performance is important and helpful for designer to evaluate and optimize converter design. The most concerned switching characteristics are switching loss, dv/dt, di/dt, and turn-ON/OFF overvoltage generally. These characteristics are crucial for the design of heatsink, filter, and gate driver. Related discussions have been presented in many existing research articles as following.请将这一段进行以下要求,Move analysis 语步(内容成分)分析; Language devices和实现该功能的语言手段(某些关键专有名词提供汉语翻译)
06-13

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值