http://codeforces.com/gym/101911/problem/L

题意: 给出n个点在y1的水平线上,给出m个点在y2的水平面上,一道光线可以在这两个水平线中折射,从任意位置开始,问最多可以经过多少了点;

思路:枚举间隔,间隔多少2的k次幂;再取点数最大的;tp[n+m+1]=1e9没写,是不会更新全部都tp  1~n+m全部相同时的情况的~~

#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<cstring>
#include<iostream>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<cstdio>
#include<map>
#include<stack>
#include<string>
using namespace std;#define sfi(i) scanf("%d",&i)
#define pri(i) printf("%d\n",i)
#define sff(i) scanf("%lf",&i)
#define ll long long
#define mem(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define eps 1e-6
#define PI acos(-1)
#define lowbit(x) ((x)&(-x))
#define zero(x) (((x)>0?(x):-(x))<eps)
#define fl() printf("flag\n")
#define MOD(x) ((x%mod)+mod)%mod
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){while(b^=a^=b^=a%=b);return a;}
const int maxn=3e5+9;
const int mod=1e9+7;template <class T>
inline void sc(T &ret)
{char c;ret = 0;while ((c = getchar()) < '0' || c > '9');while (c >= '0' && c <= '9'){ret = ret * 10 + (c - '0'), c = getchar();}
}int a[maxn],b[maxn];
int tp[maxn];
int main()
{FASTIO;#define endl '\n'int n,y1;cin>>n>>y1;for(int i=1;i<=n;i++) cin>>a[i];int m,y2;cin>>m>>y2;for(int i=1;i<=m;i++) cin>>b[i];int ans=2;tp[n+m+1]=2e9+9;for(int i=2;i<=int(1e9);i<<=1){int d=i;for(int j=1;j<=n;j++) tp[j]=(a[j])%d;for(int j=1;j<=m;j++) tp[j+n]=(b[j]+d/2)%d;sort(tp+1,tp+n+m+1);int st=1;for(int j=2;j<=n+m+1;j++){if(tp[j]!=tp[j-1]){ans=max(ans,j-st);st=j;}}}cout<<ans<<endl;return 0;
}

L. Ray in the tube相关推荐

  1. L. Ray in the tube(思维暴力)

    L. Ray in the tube(思维&暴力) 思路:思维+暴力. 记:A,BA,BA,B的横坐标距离为xxx. 1.当xxx为奇数时,显然x=1x=1x=1包含所有奇数的情况. 2.当x ...

  2. L - Ray in the tube Gym - 101911L (暴力)

    ---恢复内容开始--- You are given a tube which is reflective inside represented as two non-coinciding, but ...

  3. Problem G Ray in the tube(思维)

    https://codeforces.com/gym/101911/problem/L 题意 在二维坐标系中给出两个直线 y = a, y = b.在这两条直线上分别有n个和m个传感器,可以任意选两个 ...

  4. 【杂题】cf1041fF. Ray in the tube

    死于没有处理边界 题目描述 题目大意 在两面镜子上各选定一个整数位置的点 A 与 B,并从其中一个点向另一个射出一条光线,使得接收到光线的传感器数量尽可能的多.传感器不重叠. 题目分析 我们来初步考虑 ...

  5. Codeforces Round #509 (Div. 2) F. Ray in the tube(思维)

    题目链接:http://codeforces.com/contest/1041/problem/F 题意:给出一根无限长的管子,在二维坐标上表示为y1 <= y <= y2,其中 y1 上 ...

  6. CF1041F Ray in the tube构造_思维

    不难发现起点必定是一个点. 每次间隔的距离一定是 2k2^k2k,关键就是要判断两点是否在同一跳跃距离上可被同时覆盖. 我们可以对上边进行 x1≡x_{1}\equivx1​≡ x2mod(2∗dx) ...

  7. cf1041F. Ray in the tube

    链接 点击跳转 题解 稍微瞎在纸上画一画,会发现一个问题,假设线端在横轴上的投影长度为www,那么w=3w=3w=3的情况可以被w=1w=1w=1的情况替代 如下: 但是w=4w=4w=4的情况却不行 ...

  8. CF刷题——2500难度的几道题

    1.D. Beautiful numbers 题意:Beautiful Numbers定义为这个数能整除它的所有位上非零整数.问[l,r]之间的Beautiful Numbers的个数. 数位 DP: ...

  9. 做题记录 To 2019.2.13

    2019-01-18 4543: [POI2014]Hotel加强版:长链剖分+树形dp. 3653: 谈笑风生:dfs序+主席树. POJ 3678 Katu Puzzle:2-sat问题,给n个变 ...

  10. Unity ToLua 中Update的调用流程

    1.首先注册Lua中的update函数 LuaState.cs 其中的OpenBaseLuaLibs() public void Start(){ #if UNITY_EDITORbeStart = ...

最新文章

  1. PacBio Sequel概述
  2. Linux系统下Oracle11g r1的安装之四: 开始安装Oracle
  3. 在Delphi程序中应用IE浏览器控件
  4. O2O产品经理,请多关注屏幕之外
  5. php 二维数组字母排序,PHP二维数组获取第一个中文首字母并排序 筋斗云网络
  6. Linux rpm 命令参数使用详解[介绍和应用]
  7. J2Pay –实施网关
  8. java 0-9所有排列_java实现:键盘输入从0~9中任意5个数,排列组合出所有不重复的组合,打印出来...
  9. Postgres主进程文件—postmaster.pid
  10. asp.net EF+MVC2实战2
  11. Python学习笔记:利用timeit计算函数调用耗时
  12. unity小技巧总结
  13. 揭露动画(Reveal Effect)实现时的注意事项(附上bug-logcat)...
  14. Linux下SPI Flash-W25Q64驱动调试
  15. java最简单的打印日历表_java实现打印日历
  16. Redis cluster Hget hash field value异常分析案例--一个空格带来的惨案
  17. 鸿蒙DevEco Studio3.0——HelloWorld开发及模拟器运行
  18. java实现阿里云图片文字识别
  19. linux下xz文件如何解压,tar.xz文件如何解压
  20. latex强制图片标题居中

热门文章

  1. python变异系数_使用Python进行描述性统计 【目录】 1 描述性统计是什么? 2 使用NumPy和SciPy进行数 ......
  2. 艾可森 mysql,国足进世界杯有戏!巴西归化球员表决心:中国对我好,我必须努力...
  3. Matlab绘制实心圆和实心圆点
  4. 凯恩斯乘数到底有多么神奇?
  5. nuc10fnh寒霜峡谷linux,英特尔(Intel)寒霜峡谷NUC10i5FNH使用体验
  6. 新版淘客订单API【需token】
  7. [论文总结] 深度学习在农业领域应用论文笔记3
  8. 系统找不到指定的文件
  9. Linux Socket编程实战第1季第1部分-熊健-专题视频课程
  10. Webpack的使用——进阶篇