IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2)-A - Bear and Three Balls-水题

http://codeforces.com/contest/653/problem/A


直接判断有没连在一起的3个数就好了

#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;

const double pi=acos(-1.0);
double eps=0.000001; 
__int64 vis1[1000006];
__int64 vis2[1000006];  
__int64 when1[1000006];
__int64 when2[1000006]; 
__int64 gcdc(__int64 a,__int64 b){  
    if(b==0)  
        return a;   
	return gcdc(b,a%b);  
}  
__int64 t,p,c;
void exgcd(__int64 a,__int64 b,__int64&d,__int64&x,__int64&y)//ax+by=gcd(a,b)
{
    if(!b)
    {
        d=a;
        x=1;
        y=0;
    }
    else
    {
        exgcd(b,a%b,d,y,x);
        y-=x*(a/b);
    }
}

int vis[1888];
int main()
{
  int i,x;
 int n;
 cin>>n;
 for (i=1;i<=n;i++)
 {cin>>x;
	vis[x]=1;
 }	
 int flag=0;
 for (i=1;i<=1000;i++)
 {
	 if(vis[i]&&vis[i+1]&&vis[i+2]) {flag=1;break;}
 }
 if (flag) printf("YES\n");
 else printf("NO\n");
	return 0;
	
}


你可能感兴趣的:(IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2)-A - Bear and Three Balls-水题)