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. nutch2.3.1源码分析——InjectorJob

    InjectorJob实现的功能是:从种子站点文件当中读取站点信息并且将这些站点的个数.url(url以 域名:协议/端口号/路径名 设为形式存储在数据库当中,为了提高读写速度)回写到Context类 ...

  2. s19文件格式详解

    1.概述 为了在不同的计算机平台之间传输程序代码和数据,摩托罗拉将程序和数据文件以一种可打印的格式(ASCII格式)编码成s格式文件.s格式文件是Freescale推荐使用的标准文件传送格式.编译完成 ...

  3. Topcoder SRM 605 div1 题解

    日常打卡- Easy(250pts): 题目大意:你有n种汉堡包(统统吃掉-),每一种汉堡包有一个type值和一个taste值,你现在要吃掉若干个汉堡包,使得它们taste的总和*(不同的type值的 ...

  4. JDK源码分析--Collections

    1. 集合框架图 2. HashMap 成员构成 HashMap是通过"拉链法"实现的哈希表.它包括几个重要的成员变量:table, size, threshold, loadFa ...

  5. input 输入框提示信息

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  6. 支持 XML 序列化的 Dictionary

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.X ...

  7. "贪心"的考试

    先来落实比较简单的T3,T4 T3  团结的队伍 team 题目描述 众所周知,长郡信息组是一个团结友爱的优秀团队.为了弘扬团队精神,践行社会主义核心价值观,秉承朴实沉毅的校训,信息组决定外出游玩(. ...

  8. C++ string append()添加文本

    C++ string append()添加文本 1.  C++ string append()添加文本 使用append()添加文本常用方法: 直接添加另一个完整的字符串: 如str1.append( ...

  9. 嵌入式Linux支持LCD console【转】

    转自:http://blog.sina.com.cn/s/blog_664c545f0100v9zl.html 转载:http://www.mculee.cn/post/48.html [1]LCD ...

  10. C++11中的小细节--字符串的原始字面量

    原始字面量很容易理解,即不进行转义的完整字符串. 最近看了看Python,其中讲到了原始字符串. Both string and bytes literals may optionally be pr ...