CF 1041 F. Ray in the tube
F. Ray in the tube
题意:
有两条平行于x轴的直线A,B,每条直线上的某些位置有传感器。你需要确定A,B轴上任意两个整点位置$x_a$,$x_b$,使得一条光线沿$x_a→x_b$射出(碰到A,B后反射),能够碰到的传感器数量最多是多少。 每条直线上的传感器数量≤105,0≤xi≤109
分析:
很有意思的一道题。
发现和y没什么关系,只要确定$x_a$,$x_b$之间的水平距离差dx就行了。
然后寻找性质:
1、如果dx为奇数,那么dx一定可以用1来代替,并且不会更差。
2、如果dx为偶数,那么dx一定可以用2的幂来代替,并且不会更差。
于是可以枚举dx,然后判断。复杂度$O(nlognlog(10^9))$
代码:
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL; inline int read() {
int x=,f=;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-;
for(;isdigit(ch);ch=getchar())x=x*+ch-'';return x*f;
} const int N = ;
int A[N], B[N], C[N]; int main() {
int n = read();read();
for (int i = ; i <= n; ++i) A[i] = read();
int m = read();read();
for (int i = ; i <= m; ++i) B[i] = read();
int ans = ; C[n + m + ] = 1e9 + ;
for (int k = ; k <= ; k <<= ) {
for (int i = ; i <= n; ++i) C[i] = A[i] % (k + k);
for (int i = ; i <= m; ++i) C[i + n] = (B[i] + k) % (k + k);
sort(C + , C + n + m + );
for (int i = , pre = ; i <= n + m; ++i)
if (C[i] != C[i + ]) ans = max(ans, i - pre + ), pre = i + ;
}
cout << ans;
return ;
}
CF 1041 F. Ray in the tube的更多相关文章
- Codeforces Round #509 (Div. 2) F. Ray in the tube(思维)
题目链接:http://codeforces.com/contest/1041/problem/F 题意:给出一根无限长的管子,在二维坐标上表示为y1 <= y <= y2,其中 y1 上 ...
- L - Ray in the tube Gym - 101911L (暴力)
---恢复内容开始--- You are given a tube which is reflective inside represented as two non-coinciding, but ...
- Codeforces 1041F Ray in the tube (看题解)
Ray in the tube 感觉是套路题.. 如果确定一个差值x我们如何取确定答案呢, 我们把a[ i ] -> a[ i ] % (2 * x), 把b[ i ] -> (b[ i ...
- CF 633 F. The Chocolate Spree 树形dp
题目链接 CF 633 F. The Chocolate Spree 题解 维护子数答案 子数直径 子数最远点 单子数最长直径 (最长的 最远点+一条链) 讨论转移 代码 #include<ve ...
- Codeforces | CF1041F 【Ray in the tube】
昨天晚上全机房集体开\(Div2\),因为人傻挂两次\(B\)题的我开场就\(rank2000+\dots qwq\)于是慌乱之中的我就开始胡乱看题(口胡),于是看了\(F\dots\)(全机房似乎也 ...
- [CF1041F Ray in the tube][数学]
http://codeforces.com/contest/1041/problem/F 题目大意: 下边界有n个给定点,上边界有m个给定点,可以从任意一个点发出一条激光,激光碰到边界会反射 激光到达 ...
- 【杂题】cf1041fF. Ray in the tube
死于没有处理边界 题目描述 题目大意 在两面镜子上各选定一个整数位置的点 A 与 B,并从其中一个点向另一个射出一条光线,使得接收到光线的传感器数量尽可能的多.传感器不重叠. 题目分析 我们来初步考虑 ...
- CF #271 F Ant colony 树
题目链接:http://codeforces.com/contest/474/problem/F 一个数组,每一次询问一个区间中有多少个数字可以整除其他所有区间内的数字. 能够整除其他所有数字的数一定 ...
- CF 494 F. Abbreviation(动态规划)
题目链接:[http://codeforces.com/contest/1003/problem/F] 题意:给出一个n字符串,这些字符串按顺序组成一个文本,字符串之间用空格隔开,文本的大小是字母+空 ...
随机推荐
- asp.net 一般处理程序实现网站验证码
使用VerifyCode.ashx一般处理程序生成验证码,实现如下: using System; using System.Drawing; using System.Web; using Syste ...
- [翻译] JFMinimalNotifications
JFMinimalNotifications This is an iOS UIView for presenting a beautiful notification that is highly ...
- [翻译] InstagramPhotoPicker
InstagramPhotoPicker Present Image Picker like Instagram. 展示图片选择器,像Instagram这款应用一样. Installation - 安 ...
- Linux内核态和用户态
两张图说明Linux内核态和用户态之间的关系
- Linux 系统开机自启的配置文件
程序开机启动的配置文件(/etc/rc.local) # 系统级别 ntsysv # 图形界面设置自启程序 chkconfig(/etc/init.d/sshd) 处理开机启动的文件 # 用户级别 # ...
- RedHat 7 安装PostgreSQL 10.5
系统环境 Redhat: Version: 7.4.1708 Architecture: x86_64 Address: 10.127.1.11 User: root Uassword: redhat ...
- SQL Sever——妙用种子列
/****** Script for SelectTopNRows command from SSMS ******/ SELECT TOP 1000 [OFFRCD_STATUS_ID] ,[OFF ...
- GNSS基础(持续更新)
1.整周模糊度成功率 可参考文献:GNSS整周模糊度概率特性 2.正太分布 见百度百科 https://baike.baidu.com/item/%E6%AD%A3%E6%80%81%E5%88%86 ...
- 线段树&&线段树的创建线段树的查询&&单节点更新&&区间更新
目录 线段树 什么是线段树? 线段树的创建 线段树的查询 单节点更新 区间更新 未完待续 线段树 实现问题:常用于求数组区间最小值 时间复杂度:(1).建树复杂度:nlogn.(2).线段树算法复杂度 ...
- Java并发编程--4.Executor框架
简介 Executor框架是启动,管理线程的API, 它的内部实现是线程池机制,它有很多好处,比如使任务提交和任务执行解耦合,防止this逃逸:它的主要API包括: Executor, Execut ...