HNU11376:Golf Bot
| 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. |
| 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 |
| 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的更多相关文章
- LA6886 Golf Bot(FFT)
题目 Source https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page= ...
- UVALive 6886 Golf Bot FFT
Golf Bot 题目连接: http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=129724 Description Do ...
- UVALive - 6886 Golf Bot 多项式乘法(FFT)
题目链接: http://acm.hust.edu.cn/vjudge/problem/129724 Golf Bot Time Limit: 15000MS 题意 给你n个数,m个查询,对于每个查询 ...
- [Swerc2014 C]Golf Bot
题意:给你N个数字,每次利用这N个数字中最多两个数字进行加法运算,来得到目标中的M个数字. Solution: 我们先来看看多项式乘法:\(A(x)=\sum_{i=0}^{n-1}a_ix^i\), ...
- Gym100783C Golf Bot(FFT)
https://vjudge.net/problem/Gym-100783C 题意: 给出n个数,然后有m次查询,每次输入一个数x,问x能否由n个数中2个及2个以下的数相加组成. 思路:题意很简单,但 ...
- UVALIVE6886 Golf Bot (FFT)
题意:打高尔夫 给你n个距离表示你一次可以把球打远的距离 然后对于m个询问 问能否在两杆内把球打进洞 题解:平方一下就好 注意一下x0的系数为1表示打一杆 才发现数组应该开MAXN * 4 之前写的题 ...
- Gym 100783C Golf Bot FFT
大致题意: 给你N个整数和M个整数,问这M个数中,有几个数可以表达成那N个整数中一个或者两个整数的和. 分析: 算是半个裸的FFT.FFT可以用来在nlongn时间内求高精度乘法,我们先模拟一下乘法. ...
- FFT题集
FFT学习参考这两篇博客,很详细,结合这看,互补. 博客一 博客二 很大一部分题目需要构造多项式相乘来进行计数问题. 1. HDU 1402 A * B Problem Plus 把A和B分别当作多项 ...
- 《HelloGitHub》之GitHub Bot
起因 我在github上发起了一个开源项目:<HelloGitHub月刊>,内容是github上收集的好玩,容易上手的开源项目. 目的:因为兴趣是最好的老师,我希望月刊中的内容可以激发读者 ...
随机推荐
- Git基本用法简介
一. git和svn的主要区别 git是一个分布式的版本控制工具,而svn是一个集中式版本控制工具. 二. git工具安装 首先下载git:https://gi ...
- python注解(装饰器)的用法
带参数的要用三层def,第一层写注解里的参数,第二层写函数,第三层写具体逻辑. 如果是不带参数的注解,直接使用后两层即可 def needPermission(permissionstr): def ...
- 转:LinkedHashMap使用(可以用来实现LRU缓存)
1. LinkedHashMap概述: LinkedHashMap是HashMap的一个子类,它保留插入的顺序,如果需要输出的顺序和输入时的相同,那么就选用LinkedHashMap. LinkedH ...
- 洛谷P3112 [USACO14DEC]后卫马克Guard Mark
题目描述 Farmer John and his herd are playing frisbee. Bessie throws the frisbee down the field, but it' ...
- C语言fopen函数了解
fopen()函数功能:open a file. 原型:FILE * fopen(const char * path,const char * mode); 需要#include<stdio.h ...
- Servlet4.0 注解不生效解决
当我们创建好一个4.0的servlet 生成的注解大概是这样 name=xxxxx 默认的是不具有效果的 你可以有两种方式 1.去掉属性name,3.0就是这样子的 2.非要有name属性 请加上u ...
- 随手看的一本书《java微服务》,测试成功了其中的第一个样例
静态语言,JAVA应该多了解,结合微服务,DOCKER,再搞搞SPRING CLOUD,就能跟上时代了. 对了,链一个买书的地址: https://item.jd.com/12089180.html ...
- Razor 常用方法
结合wdate使用 //WdatePicker控件时间限制 @Html.TextBoxFor(model => model.BookingStart, new { @onClick = &quo ...
- 我在16ASPX下了一个系统是ACCESS和VS2005做的我想把那个连接数据库的'DB_16aspx'的名字改了进不了了可是?
靠,在web.config或者其他配置文件中把数据库连接字符串改称你的新名字不就行了
- (2).net web api 请求方式与参数
一.GET 二.POST 如果方法名前缀不带GET 默认为POST请求方法 1.无参数 2.带一个参数 客户端请求时,名称必须为空,不能是dictCategory.不是空的话,会返回空数据 [ ] 3 ...
