Ray in the tube

感觉是套路题。。

如果确定一个差值x我们如何取确定答案呢, 我们把a[ i ] -> a[ i ] % (2 * x), 把b[ i ] -> (b[ i ] + k) % (2 * x),

值相同的都能同时射到。

同时我们能发现, 对于一个差值x如果它有奇数因子, 把它除掉之后会更优, 所以我们要check的x只有2的幂次。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long using namespace std; const int N = 2e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1e-;
const double PI = acos(-); map<int, int> Map; int n, m, y, ans, a[N], b[N];
int main() {
scanf("%d%d", &n, &y);
for(int i = ; i <= n; i++) scanf("%d", &a[i]);
scanf("%d%d", &m, &y);
for(int i = ; i <= m; i++) scanf("%d", &b[i]);
for(int k = ; k < 1e9 + ; k *= ) {
Map.clear();
for(int i = ; i <= n; i++) Map[a[i] % ( * k)]++;
for(int i = ; i <= m; i++) Map[(b[i] + k) % ( * k)]++;
for(auto& t : Map) ans = max(ans, t.se);
}
ans = max(ans, );
printf("%d\n", ans);
return ;
} /*
*/

Codeforces 1041F Ray in the tube (看题解)的更多相关文章

  1. Codeforces.1041F.Ray in the tube(思路)

    题目链接 \(Description\) 有两条平行于\(x\)轴的直线\(A,B\),每条直线上的某些位置有传感器.你需要确定\(A,B\)轴上任意两个整点位置\(x_A,x_B\),使得一条光线沿 ...

  2. Codeforces 229E Gifts 概率dp (看题解)

    Gifts 感觉题解写的就是坨不知道什么东西.. 看得这个题解. #include<bits/stdc++.h> #define LL long long #define LD long ...

  3. Codeforces 1155F Delivery Oligopoly dp(看题解)

    看别人写的才学会的... 我们考虑刚开始的一个点, 然后我们枚举接上去的一条一条链, dp[mask]表示当前已经加进去点的状态是mask所需的最少边数. 反正就是很麻烦的一道题, 让我自己写我是写不 ...

  4. Codeforces 380D Sereja and Cinema (看题解)

    Sereja and Cinema 首先我们可以发现除了第一个人, 其他人都会坐在已入坐人的旁边. 难点在于计算方案数.. 我们可以从外往里把确定的人用组合数算上去,然后缩小范围. #include& ...

  5. Codeforces 442D Adam and Tree dp (看题解)

    Adam and Tree 感觉非常巧妙的一题.. 如果对于一个已经建立完成的树, 那么我们可以用dp[ i ]表示染完 i 这棵子树, 并给从fa[ i ] -> i的条边也染色的最少颜色数. ...

  6. Codeforces 915G Coprime Arrays 莫比乌斯反演 (看题解)

    Coprime Arrays 啊,我感觉我更本不会莫比乌斯啊啊啊, 感觉每次都学不会, 我好菜啊. #include<bits/stdc++.h> #define LL long long ...

  7. Codeforces 1101F Trucks and Cities dp (看题解)

    Trucks and Cities 一个很显然的做法就是二分然后对于每个车贪心取check, 这肯定会TLE, 感觉会给人一种贪心去写的误导... 感觉有这个误导之后很难往dp那个方向靠.. dp[ ...

  8. Codeforces 596D Wilbur and Trees dp (看题解)

    一直在考虑, 每一段的贡献, 没想到这个东西能直接dp..因为所有的h都是一样的. #include<bits/stdc++.h> #define LL long long #define ...

  9. Codeforces 965E Short Code 启发式合并 (看题解)

    Short Code 我的想法是建出字典树, 然后让后面节点最多的点优先向上移到不能移为止, 然后gg. 正确做法是对于当前的节点如果没有被占, 那么从它的子树中选出一个深度最大的点换到当前位置. 用 ...

随机推荐

  1. WebStrom设置默认浏览器

  2. C# 一般处理程序下载文件

    using System; using System.Collections; using System.Data; using System.Linq; using System.Web; usin ...

  3. Java EE之分页器设计

    由于数据库实训的课程设计,在做项目过程中,需要使项目更加规范的结构和各层间责任分离.无疑地,分页器是其中之一. 1. 本文仅陈述分页器如何实现,关于分页器的其他概念,请自行搜索其他网络资源. 2. 关 ...

  4. IE8以下浏览器设置Title的问题

    ie8不支持网页title的如下写法  $('title').text('标题');  $('title').html('标题'); 在ie8中,正确写法: document.title = &quo ...

  5. 前端mock数据的几种方式

    方式 备注 本地php服务架设 直接输出json 使用在线mock服务 如easyMock.apizza.Rap1\2 , 可以远程协作  本地node服务:koa+mongodb    本地node ...

  6. Eclipse通用设置

    分类 Eclipse分为64位.32位,安装版.免安装版 查看Eclipse版本信息 Help - About Eclipse - Installation Details

  7. android AysncTask使用

    1.继承AysncTask类 例子: class downloadTask extends AsyncTask<Void,Integer,Boolean> 第一个参数是传入的参数 第二个参 ...

  8. 深层揭密extern "C"

    一. extern "C" 包含双重含义,从字面上即可得到:首先,被它修饰的目标是“extern”的:其次,被它修饰的目标是“C”的.让我们来详细解读这两重含义. (1) 被ext ...

  9. Majority Element(169) && Majority Element II(229)

    寻找多数元素这一问题主要运用了:Majority Vote Alogrithm(最大投票算法)1.Majority Element 1)description Given an array of si ...

  10. Linux内存管理4---虚拟地址空间管理

    1.前言 本文所述关于内存管理的系列文章主要是对陈莉君老师所讲述的内存管理知识讲座的整理. 本讲座主要分三个主题展开对内存管理进行讲解:内存管理的硬件基础.虚拟地址空间的管理.物理地址空间的管理. 本 ...