n*n的格子,只能在边界(出去角)上放棋子,一个一个移动到对面。游戏失败的条件有三个,看原文。
问最多能放几个棋子。
POINT:
找规律,一个for(2-n-1)就行。
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include<algorithm>
using namespace std;
#define LL long long
const int maxn = 1111;
int a[maxn],b[maxn];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
for(int i=1;i<=m;i++){
int x,y;
scanf("%d %d",&x,&y);
a[x]=1;
b[y]=1;
}
int ans=0;
for(int i=2;i<=n-1;i++)
{
if(a[i]+b[i]==1)
ans++;
if(a[i]+b[i]==0)
{
ans+=2;
if(n%2==1&&i==(n+1)/2)
ans--;
}
}
printf("%d\n",ans);
}