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. LR(0)文法项目集规范族、DFA和分析表的构建实例

    最近在复习编译原理,考试之前以为自己懂了,眼高手低就没去实践.结果一考试出问题了.... 学习就要脚踏实地,容不得半点模糊.凭着侥幸心理很危险的.以后要引以为戒啊. 特别写出这篇文章 :一来总结一下这 ...

  2. Shell + crontab 实现日志压缩归档

    Shell + crontab 实现日志压缩归档 crontab # archive the ats log days. */ * * * * root /bin/>& shell #! ...

  3. 发现一sonar-runner bug

    最近在使用sonar-runner做代码扫描, 在windows环境运行多模块的扫描ok,但是在linux上sonar-runner扫描多模块报错: 先贴sonar-project.propertie ...

  4. http raw post 之理解

    参考链接: https://imququ.com/post/four-ways-to-post-data-in-http.html http://blog.csdn.net/leyangjun/art ...

  5. JavaScript学习 - 基础(三) - 运算符

    js运算符 1.算数运算符 包括 加(+) .减-() .乘(*).除(/).余数(%) 减号 还可以表示为 负号 例如: -1,-3 加号 还可以用于字符串拼接 例如: 'a' + 'b' = 'a ...

  6. Java读取Excel文件转换成JSON并转成List——(七)

    Jar包

  7. 【转】shell编程下 特殊变量、test / [ ]判断、循环、脚本排错

    [转]shell编程下 特殊变量.test / [ ]判断.循环.脚本排错 第1章 shell中的特殊变量 1.1 $# $# 表示参数的个数 1.1.1 [示例]脚本内容 [root@znix ~] ...

  8. 使用python中的matplotlib 画图,show后关闭窗口,继续运行命令

    使用python中的matplotlib 画图,show后关闭窗口,继续运行命令 在用python中的matplotlib 画图时,show()函数总是要放在最后,且它阻止命令继续往下运行,直到1.0 ...

  9. dblink 退出 session

    以dblink的表现为例,我一直认为dblink的远程连接session仅在操作(select,dml)发生时短期存在,在操作完成后依据一定条件保留或退出. 而事实并非如此,随便使用一个远程查询语句如 ...

  10. 018_mac写权限的问题

    一. 有时候运行一些软件的时候,操作系统下的文件没有写权限.我在使用"HostAdmin App"时碰到了这个问题,google的链接供参考:https://code.google ...