HDU 5522 Numbers

水题

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int tot[2000];
int n;
int a[105];

int main()
{
    while(~scanf("%d",&n)){
    memset(tot,0,sizeof tot);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        tot[a[i]]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            tot[a[i]]--;
            tot[a[j]]--;
            if(tot[a[i]+a[j]]>0) {ans=1;break;}
            tot[a[i]]++;
            tot[a[j]]++;
        }
        if(ans==1) break;
    }
    if(ans==0) printf("NO
");
    else printf("YES
");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zufezzt/p/4927470.html