给你一串数字,问你可不可以把数字分成奇数个串,且每个串的数字个数都是奇数,且第一个和最后一个水数都是奇数。
POINT:
可知 奇数个 奇数加起来肯定是奇数。所以只有奇数个数字的串且头尾是奇数才满足条件。其他都是NO。
别想的太复杂了。
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
using namespace std;
#define LL long long
const int inf = 0x3f3f3f3f;
const int maxn = 111;
int a[maxn];
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
if(a[1]%2==0||a[n]%2==0)
{
printf("NO\n");
return 0;
}
else
{
if(n%2==1)
{
printf("YES\n");
}
else
printf("NO\n");
}
}