HNU11376:Golf Bot
2017-05-03 17:55
211 查看
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 ,b ; 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; }
相关文章推荐
- UVALive 6886 Golf Bot
- 【暴力预处理+剪枝/bitset】Golf Bot UVALive - 6886
- UVALive 6886 (LA 6886) Golf Bot FFT
- UVALive 6886 Golf Bot FFT
- UVALive6886 Golf Bot[FFT]
- UVALive - 6886 Golf Bot 多项式乘法(FFT)
- UVALive 6886 Golf Bot (FFT)
- UVALive - 6886 Golf Bot
- BOT’S DAY『原创』
- JAVA中[人工无脑]系统(chatbot)的实现
- About the W32/Codbot-O —— DirectX Graphics (dxdmain)
- SEO工具:Googlebot 有哪几种?
- PHP BOT
- bot定时任务程序
- PVCBOT【12号A版】索道游者--吊绳攀爬机器人
- buildbot steps
- How to build a Bot Trap and keep bad bots away from a web site
- atc游戏bot
- buildbot&nbsp;+&nbsp;bazaar&nbsp;+&nbsp;mysql的测试…
- 用ROS控制KUKA youbot 的5自由度机械臂和夹子