转向

0309 2021-04-29 19:05:55

#include<cstdio>
int main(){
	int a[10009];
	int n;
	scanf("%d", &n);
	for (int i=1; i<=n; i++){
		scanf("%d",&a[i]);
	}
	int d = 0;//bei=0 dong=1 nan=2 xi=3
	int ans=0;
	for (int i=1; i<=n; i++){
		if (a[i] == 0){
			d = d + 3;
			if (d % 4 == 2){
				ans++;
			}
		}
		if (a[i] == 1){
			d = d + 1;
			if (d % 4 == 2){
				ans++;
			}
		}
		if (a[i] == 2){
			d = d + 2;
			if (d % 4 == 2){
				ans++;
			}
		}
	}
	printf("%d", ans);
	return 0;
}