Problem description

Input

The first line has one integer: N, the number of different distances the Golf Bot can shoot. Each of the following N lines has one integer, ki, the distance marked in position i of the knob.

Next line has one integer: M, the number of holes in this course. Each of the following M lines has one integer, dj , the distance from Golf Bot to hole j.

1<=N,M<=200 000

1<=ki,dj<=200 000

Output

You should output a single integer, the number of holes Golf Bot will be able to complete. Golf Bot cannot shoot over a hole on purpose and then shoot backwards.

Sample Input
3
1
3
5
6
2
4
5
7
8
9
Sample Output
4
Problem Source
HNU Contest 

题意:

打高尔夫。一球能打n种距离。有m个洞,给出每一个洞的位置。问两杆之内,在仅仅能往前打的情况下。能进的有几种洞

思路:

数据非常大?但你要看有30S。明摆着告诉你暴力可行

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std; #define ls 2*i
#define rs 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define LL long long
#define N 200005
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define rank rank1
const int mod = 1000000007; int hsh[N*2];
int a[N],b[N]; int main()
{
int n,m,i,j,k;
while(~scanf("%d",&n))
{
MEM(hsh,0);
for(i = 0; i<n; i++)
{
scanf("%d",&a[i]);
hsh[a[i]] = 1;
}
sort(a,a+n);
for(i = 0; i<n; i++)
{
for(j = i; j<n; j++)
{
hsh[a[i]+a[j]] = 1;
}
}
int ans = 0;
scanf("%d",&m);
for(i = 0; i<m; i++)
{
scanf("%d",&b[i]);
if(hsh[b[i]])
ans++;
}
printf("%d\n",ans);
} return 0;
}

HNU11376:Golf Bot的更多相关文章

  1. LA6886 Golf Bot(FFT)

    题目 Source https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page= ...

  2. UVALive 6886 Golf Bot FFT

    Golf Bot 题目连接: http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=129724 Description Do ...

  3. UVALive - 6886 Golf Bot 多项式乘法(FFT)

    题目链接: http://acm.hust.edu.cn/vjudge/problem/129724 Golf Bot Time Limit: 15000MS 题意 给你n个数,m个查询,对于每个查询 ...

  4. [Swerc2014 C]Golf Bot

    题意:给你N个数字,每次利用这N个数字中最多两个数字进行加法运算,来得到目标中的M个数字. Solution: 我们先来看看多项式乘法:\(A(x)=\sum_{i=0}^{n-1}a_ix^i\), ...

  5. Gym100783C Golf Bot(FFT)

    https://vjudge.net/problem/Gym-100783C 题意: 给出n个数,然后有m次查询,每次输入一个数x,问x能否由n个数中2个及2个以下的数相加组成. 思路:题意很简单,但 ...

  6. UVALIVE6886 Golf Bot (FFT)

    题意:打高尔夫 给你n个距离表示你一次可以把球打远的距离 然后对于m个询问 问能否在两杆内把球打进洞 题解:平方一下就好 注意一下x0的系数为1表示打一杆 才发现数组应该开MAXN * 4 之前写的题 ...

  7. Gym 100783C Golf Bot FFT

    大致题意: 给你N个整数和M个整数,问这M个数中,有几个数可以表达成那N个整数中一个或者两个整数的和. 分析: 算是半个裸的FFT.FFT可以用来在nlongn时间内求高精度乘法,我们先模拟一下乘法. ...

  8. FFT题集

    FFT学习参考这两篇博客,很详细,结合这看,互补. 博客一 博客二 很大一部分题目需要构造多项式相乘来进行计数问题. 1. HDU 1402 A * B Problem Plus 把A和B分别当作多项 ...

  9. 《HelloGitHub》之GitHub Bot

    起因 我在github上发起了一个开源项目:<HelloGitHub月刊>,内容是github上收集的好玩,容易上手的开源项目. 目的:因为兴趣是最好的老师,我希望月刊中的内容可以激发读者 ...

随机推荐

  1. LNMP下安装phpmyadmin的一个小错误解决办法

    环境:ubuntu16.04 + nginx1.10.0 + php7.04 + mysql5.6 安装phpmyadmin之后tail nginx 的错误日志,提示以下: 2016/06/30 15 ...

  2. [bzoj1051][HAOI2006]受欢迎的牛——强连通分量

    题目大意: 给定一个有向图,求能够被其他所有点访问到的点的个数. 题解: 首先,这个题我在洛谷上AC了,但是bzoj上WA,不知道为什么. 说一下解法. 首先,我们进行scc分解,可以知道, 如果一个 ...

  3. 简单粗暴!解决锐捷强制关闭VMware NAT Service的问题(图文教程)

    众所周知毒瘤的锐捷会定时强制关闭NAT服务,导致虚拟机连不上网,进而你的虚拟机就成了孤儿,只能玩单机. 在一番百度后,得到了一种神仙破解办法.原理是把锐捷关闭服务时所用的搜索关键字改掉,这样锐捷就搜不 ...

  4. GPS经纬度的表示方法及换算

    想要认识GPS中的经纬度,就必须先了解GPS,知道经纬度的来源: 1. GPS系统组成 GPS是 Gloabal Positioning System 的简称,意为全球定位系统,主要由地面的控制站.天 ...

  5. Relation(NOIP模拟赛)(二分图染色)

    原题: Description 有n个人,编号为1àn,告诉你那些人之间是不友好的.现在,让你将这n个人分成两组,使得每一组之内的人是互相友好的,如果可以分成两组,则输出如何分组的,如果不可以分成两组 ...

  6. 杭电oj2000-2011

    2000  ASCII码排序 #include <stdio.h> int main(){ char a,b,c,t; while(scanf("%c%c%c", &a ...

  7. Sqlite 约束条件 Constraints

    一.约束 Constraints 我们在数据库中存储数据的时候,有一些数据有明显的约束条件. 比如一所学校关于教师的数据表,其中的字段列可能有如下约束: 年龄 - 至少大于20岁.如果你想录入一个小于 ...

  8. UVALIVE 2955 Vivian's Problem

    参考: http://blog.csdn.net/acm_cxlove/article/details/7860735 感觉这里需要记录一下 #include <map> #include ...

  9. 加密中的salt是啥意思

    今天在stackoverflow上查看python的md5的问题,提到,除了简单的加密外,还可以加入一点salt 啥意思?百度一下看到:(https://zhidao.baidu.com/questi ...

  10. 这绝对是有史以来最详细的web前端学习路线

    定要善用开发者工具.firefox的firebug和Chrome的F12都是很好的选择,用好了这个必会发现他带给你的帮助比看一本书更多.你把firebug摸透了你还担心对DOM理解不够?考虑到未来,h ...