首页 > 代码库 > HDU-3833-YY's new problem

HDU-3833-YY's new problem

题目链接

http://acm.hdu.edu.cn/showproblem.php?pid=3833

hash,即可。AC

我的代码

#include<stdio.h>

int a[10005];
int hash[10005];

int main(void)
{
int n,i,j,k,l,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",a+i);
hash[a[i]]=i;
}
k=0;
for(i=0;i<n;i++)
{
for(j=i+2;j<n;j++)
{
if((a[i]+a[j])%2==0)
{
l=(a[i]+a[j])/2;
if(i<hash[l]&&hash[l]<=j)
{
k=1;
break;
}
}
}
if(k)
break;
}
if(k)
printf("Y\n");
else
printf("N\n");
}
}

HDU-3833-YY's new problem