首页 > 其他 > 详细

poj 2366 Sacrament of the sum

时间:2016-08-17 19:43:18      阅读:182      评论:0      收藏:0      [点我收藏+]

题目连接:http://poj.org/problem?id=2366

题意:给出一个N,N个数,一个M,M个数,问在N个数取一个数和M个数中取一个数加起来是否可能等于10000,范围是-32768~32767.

分析:水题,直接加40000,然后用数组记录就好。

代码:

技术分享
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
#define Max(a,b) (a>b)?a:b
#define lowbit(x) x&(-x)
  int n,m,vis[1000000]={0},t,ff=0;
int main()
{

    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&t);
        vis[t+40000]=1;
    }
    scanf("%d",&m);
    for(int j=0;j<m;j++)
    {
        scanf("%d",&t);
        if(vis[50000-t])
            ff=1;
    }
    if(ff)
        puts("YES");
    else
        puts("NO");
}
View Code

 

poj 2366 Sacrament of the sum

原文:http://www.cnblogs.com/wwdf/p/5781351.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!