/* ***********************************************
Author :小蔡虎
Created Time :2016/
File Name :E:\2016ACM\HDU
状态 :
************************************************ */
#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<iostream>
#include<time.h>
#define PI 3.141592654
#define MA 1000010
using namespace std;
/*思路:
首先明白2只蚂蚁碰撞后跟相互穿过去一样,假设一只蚂蚁向右走,那这只蚂蚁
右边向左走的蚂蚁都会被感染,这只蚂蚁左边向右走的都会被感染。分析,只要
面向这只蚂蚁的都将被感染。
sum=左边+右边+自己
*/
int main()
{
int n,a[101],s=0,i,t=0,k=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=1;i<n;i++)
{
if(a[i]>0&&abs(a[i])<abs(a[0]))
{
s++;
k=1;
}
if(a[i]<0&&abs(a[i])>abs(a[0]))
{
s++;
t=1;
}
}
if((k==0&&t==1&&a[0]<0)||(k==1&&t==0&&a[0]>0)||(k==0&&t==0))
{
s=1;
}
else
s++;
printf("%d\n",s);
return 0;
}
2014蓝桥杯 第五届 蚂蚁感冒
最新推荐文章于 2021-01-21 14:34:00 发布