Source Code
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <stdio.h>
#include<iterator>
#include<memory.h>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
const int oo = 1e9 + 10;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
void solve() {
	int n;
	scanf("%d", &n);
	vector<int>v(n);
	for (int i = 0; i < n - 1; i++)
		scanf("%d", &v[i]);
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		bool ok = false;
		while (i < n - 1 && v[i] % 2 == 0) {
			i++;
			ok = true;
		}
		if (ok)
			ans++;
	}
	printf("%d\n", ans - 1);
}
int t = 1;
int main() {
	//freopen("input.txt", " r", stdin);
	//scanf("%d", &t);
	while (t--) solve();
}
Copy
Teleportation Malik
GNU G++17
0 ms
504 KB
Wrong Answer