time limit per test2 seconds memory limit per test512 megabytes inputstandard input outputstandard output A robot is standing at the
origin of the infinite two-dimensional plane. Each second the robot
moves exactly 1 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 n 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 n (1≤n≤1000) — the
number of steps the robot makes.Output Print a single integer — the number of different possible
locations after exactly n steps.Examples inputCopy 1 outputCopy 4 inputCopy 2 outputCopy 4 inputCopy 3
outputCopy 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–√ meters
north-west, north-east, south-west, or south-east.
盲猜是和奇偶有关,所以先试着打个表 发现果然有迹可循
奇数时[(n-3)/2+3]*(n+1)
偶数时(n/2+1)^2
具体证明?可能用数学归纳法可以整出来
//cyc
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define vector<int> VI
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mst(a) memset(a,0,sizeof a)
using namespace std;
typedef pair<int,int> pii;
int rec[35];
bool vis[31][31][31];
void dfs(int x,int y,int flag,int step)
{
if(x>8||x<0||y>8||y<0||step>8)return;
if(vis[x][y][step]!=1)rec[step]++;
vis[x][y][step]=1;
if(flag&1){
dfs(x+1,y,flag^1,step+1);
dfs(x-1,y,flag^1,step+1);
}
else{
dfs(x,y+1,flag^1,step+1);
dfs(x,y-1,flag^1,step+1);
}
}
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// dfs(4,3,1,1);
// dfs(4,5,1,1);
// dfs(3,4,0,1);
// dfs(5,4,0,1);
/* for(int i=1;i<=8;i++){
cout<<i<<" "<<rec[i]<<endl;
}*/
int n;
while(cin>>n){
if(n==1||n==2){
cout<<4<<endl;
}
else {
if(n&1){
int p,q;
p=(n-3)/2+3;
q=(n-3)+4;
p=p*q;
cout<<p<<endl;
}
else{
int p=n/2;
p++;
p=p*p;
cout<<p<<endl;
}
}
}
}