CodeForces 631 A.Interview(水~)
来源:互联网 发布:不交叉拓扑图算法 编辑:程序博客网 时间:2024/06/03 11:18
Description
f(x,l,r)表示将x序列的第l个元素到第r个元素按位或后的结果,给出两个长度为n的序列,问f(a,l,r)+f(b,l,r)的最大值,1<=l<=r<=n
Input
第一行一整数n表示序列长度,之后输入两个长度为n的序列a和b(0<=ai,bi<=1e9)
Output
输出f(a,l,r)+f(b,l,r)的最大值,1<=l<=r<=n
Sample Input
5
1 2 4 3 2
2 3 3 12 1
Sample Output
22
Solution
简单题,按位或只会越来越大,所以f(a,1,n)+f(b,1,n)最大
Code
#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;#define INF 0x3f3f3f3f#define maxn 1111int n,a,b;int main(){ while(~scanf("%d",&n)) { a=b=0; for(int i=1;i<=n;i++) { int t; scanf("%d",&t); a|=t; } for(int i=1;i<=n;i++) { int t; scanf("%d",&t); b|=t; } printf("%I64d\n",(ll)a+(ll)b); } return 0;}
0 0
- CodeForces - 631A Interview (思想)水
- CodeForces 631 A.Interview(水~)
- CodeForces 631A-Interview
- Codeforces 631A - Interview
- CodeForces 631A--Interview
- CodeForces 631A Interview
- 【Codeforces 631 A Interview】
- codeforces 631A Interview
- Codeforces 631A Interview【模拟水题】
- Codeforces--631A--Interview(位运算)
- CodeForces 631A Interview(水题)
- Codeforces 631A Interview 【水题】
- CodeForces 631A 631A - Interview
- CodeForces 631 A A. Interview【枚举】
- Codeforces 631A Interview(分析&&位运算| )
- CodeForces 631A:Interview【位运算】
- Codeforces Round #344 (Div. 2) 631A Interview (DP)
- Codeforces Round #344 (Div. 2) A. Interview (位运算)
- RecyclerView使用介绍
- 常用类-包装类-Math-Object
- JVM体系结构与工作方式概览
- 手机端HTML5 input被输入法遮挡的jquery解决办法
- 中南大学第十一届大学生程序设计竞赛-COJ1902-Happy Chinese Poker
- CodeForces 631 A.Interview(水~)
- 一个acmer的感悟
- Mysql安装(linux+windows)
- 线程优先级设置
- java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger报错(lib包没有导入)
- String,StringBuffer与StringBuilder的区别??
- leetcode542
- Microsoft IIS WebDAV安全漏洞
- http重定向和转发