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\n");
    else printf("YES\n");
    }
    return 0;
}
时间: 2024-10-13 11:39:12

HDU 5522 Numbers的相关文章

HDU 6168 - Numbers | 2017 ZJUT Multi-University Training 9

/* HDU 6168 - Numbers [ 思维 ] | 2017 ZJUT Multi-University Training 9 题意: .... 分析: 全放入multiset 从小到大,慢慢筛 */ #include <bits/stdc++.h> using namespace std; const int N = 125250; int n, s[N]; int a[N], cnt; multiset<int> st; multiset<int>::it

HDU Humble Numbers (dp)

Humble Numbers Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 8   Accepted Submission(s) : 4 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description A number whose only prim

hdu 5181 numbers——思路+区间DP

题目:http://acm.hdu.edu.cn/showproblem.php?pid=5181 题解:https://www.cnblogs.com/Miracevin/p/10960717.html 原来卡特兰数的这个问题还能区间DP…… XO #include<cstdio> #include<cstring> #include<algorithm> #define ll long long using namespace std; int rdn() { in

HDU 5585 Numbers

水题. #include<cstdio> #include<cstring> char s[1000]; int main() { while(~scanf("%s",s)){ int len=strlen(s); int flag=0; if((s[len-1]-'0')%2==0) flag=1; if((s[len-1]-'0')==0||(s[len-1]-'0')==5) flag=1; int sum=0; for(int i=0;s[i];i++)

hdu 6168 Numbers

题解:和前面的多校的一道题目类似,顺序遍历的时候,a元素是比b要小的.用求出来的a去筛一遍b就可以了. #include <iostream> #include <vector> #include <map> #include <cstdio> using namespace std; vector<int>ans; int c[130000]; int main() { int m; while(~scanf("%d",&a

QBXT 2018春季DP&amp;图论班 2018.5.3 --- 区间DP专题

本文题目等来自北京大学张浩威学长的PPT. 1.区间DP:解决有关两个或以上的区间的合并或删除的问题(最大/小次数/价值.方案总数.可行性等). 2.石子合并: 有n堆石子排成一排,第i堆石子的个数为ai.每次可以将相邻两堆合并成一堆.合并的代价为两堆石子的石子个数之和.设计方案要求代价之和最小. 状态:dp[l][r]表示只考虑区间l~r的石子,将它们合并的最小代价. 状态转移:dp[l][r]=min{dp[l][r],dp[l][k]+dp[k+1][r]+s[r]-s[l-1]} l~r

hdu 3117 Fibonacci Numbers

点击此处即可传送到hdu 3117 **Fibonacci Numbers** Problem Description The Fibonacci sequence is the sequence of numbers such that every element is equal to the sum of the two previous elements, except for the first two elements f0 and f1 which are respectively

hdu 5272 Dylans loves numbers 水题

Dylans loves numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5272 Description Dylans是谁?你可以在 UOJ 和 Codeforces上看到他.在BestCoder里,他有另外一个ID:s1451900.今天的题目都和他有关哦.Dylans得到了一个数N.他想知道N的二进制中有几组1.如果两个1之间有若干个(至少一个)0

筛法暴力打表 --- hdu : 12876 Quite Good Numbers

Quite Good Numbers Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KB Total submit users: 77, Accepted users: 57 Problem 12876 : No special judgement Problem description A "perfect" number is an integer that is equal to the sum