#include "stdio.h"
#include "memory.h"
int light[10010];
int main()
{
int i, evencount1, evencount2, oddcount1, oddcount2, evencount = 0, oddcount = 0, num;
while (scanf("%d", &num) != EOF)
{
evencount1 = 0;
evencount2 = 0;
oddcount1 = 0;
oddcount2 = 0;
memset(light, 0, sizeof(light));
for (i = 0; i < num; i++)
scanf("%d", &light[i]);
for (i = 0; i < num; i++)
{
if (i % 2 == 0 && light[i] == 0)
evencount1++;
else if (i % 2 != 0 && light[i] == 1)
oddcount1++;
else if (i % 2 == 0 && light[i] == 1)
evencount2++;
else if (i % 2 != 0 && light[i] == 0)
oddcount2++;
}
evencount = evencount1 + oddcount1;
oddcount = evencount2 + oddcount2;
if (evencount > oddcount)
printf("%d\n", oddcount);
else
printf("%d\n", evencount);
}
}
zoj 1622 Switch
最新推荐文章于 2019-09-23 21:41:46 发布