JZOJ 5185. 【NOIP2017提高组模拟6.30】tty's sequence
5185. 【NOIP2017提高组模拟6.30】tty's sequence (Standard IO)
Description
Input
Output
Sample Input
input 1:
6 3
1 1 1 0 0 0
input 2:
6 3
1 1 0 1 0 0
input 3:
6 3
11 8 2 1 3 9
Sample Output
output 1
1 1
output 2
1 0
output 3
11 1
#include <cstdio>
#include <cstring>
#include <iostream>
#define N 2500007
#define LL long long
using namespace std;
int n, m;
LL a[N], Ans1, Ans2, M;
LL list[N], List[N]; LL max(LL x, LL y)
{
if (x > y) return x;
return y;
} void Pre_work()
{
for (int i = ; i <= n; i += m)
{
list[i] = a[i];
for (int j = i + ; j <= min(i + m - , n); j++)
list[j] = list[j - ] & a[j];
}
for (int i = ; i <= n; i += m)
{
List[min(i + m - , n)] = a[min(i + m - , n)];
for (int j = min(i + m - , n) - ; j >= i; j--)
List[j] = List[j + ] & a[j];
}
} int main()
{
scanf("%d%d", &n, &m);
for (int i = ; i <= n; scanf("%lld", &a[i++]), Ans1 = Ans1 | a[i - ]);
Pre_work();
for (int i = m; i <= n; i++)
{
if (i % m == )
Ans2 = max(Ans2, list[i]);
else Ans2 = max(Ans2, List[i - m + ] & list[i]);
}
printf("%lld %lld", Ans1, Ans2);
}
JZOJ 5185. 【NOIP2017提高组模拟6.30】tty's sequence的更多相关文章
- [jzoj 5178] [NOIP2017提高组模拟6.28] So many prefix? 解题报告(KMP+DP)
题目链接: https://jzoj.net/senior/#main/show/5178 题目: 题解: 我们定义$f[pos]$表示以位置pos为后缀的字符串对答案的贡献,答案就是$\sum_{i ...
- [jzoj 5177] [NOIP2017提高组模拟6.28] TRAVEL 解题报告 (二分)
题目链接: https://jzoj.net/senior/#main/show/5177 题目: 题解: 首先选出的泡泡怪一定是连续的一段 L,R 然后 L 一定属于虫洞左边界中的某一个 R 也同样 ...
- [JZOJ5185] 【NOIP2017提高组模拟6.30】tty's sequence
Description
- 【ZJOJ5186】【NOIP2017提高组模拟6.30】tty's home
题目 分析 如果直接求方案数很麻烦. 但是,我们可以反过来做:先求出所有的方案数,在减去不包含的方案数. 由于所有的路径连在一起, 于是\(设f[i]表示以i为根的子树中,连接到i的方案数\) 则\( ...
- JZOJ 5184. 【NOIP2017提高组模拟6.29】Gift
5184. [NOIP2017提高组模拟6.29]Gift (Standard IO) Time Limits: 1000 ms Memory Limits: 262144 KB Detailed ...
- JZOJ 5196. 【NOIP2017提高组模拟7.3】B
5196. [NOIP2017提高组模拟7.3]B Time Limits: 1000 ms Memory Limits: 262144 KB Detailed Limits Goto Pro ...
- JZOJ 5197. 【NOIP2017提高组模拟7.3】C
5197. [NOIP2017提高组模拟7.3]C Time Limits: 1000 ms Memory Limits: 262144 KB Detailed Limits Goto Pro ...
- JZOJ 5195. 【NOIP2017提高组模拟7.3】A
5195. [NOIP2017提高组模拟7.3]A Time Limits: 1000 ms Memory Limits: 262144 KB Detailed Limits Goto Pro ...
- NOIP2017提高组 模拟赛15(总结)
NOIP2017提高组 模拟赛15(总结) 第一题 讨厌整除的小明 [题目描述] 小明作为一个数学迷,总会出于数字的一些性质喜欢上某个数字,然而当他喜欢数字k的时候,却十分讨厌那些能够整除k而比k小的 ...
随机推荐
- EditPlus常用操作
EditPlus注册码在线生成 http://www.jb51.net/tools/editplus/ 随意填写个用户名,生成对应的密码就可以使用editplus了 EditPlus常用快捷键 编代码 ...
- 封装一个帮助类来写文件到android外置存储器上
项目地址:点击打开 项目简介:写文件到android外置存储器的一个帮助类,和它的demo程序 它是如何工作的呢? 1.创建 AppExternalFileWriter 对象并传递context(上下 ...
- Java 编码规范有感
应小组要求,开发测试都需要考阿里编码规范,因此,相当于是突击了一下关于编码规范方面的知识,目前做的项目后期需要进行项目迁移,数据迁移,功能迁移... 各种迁移... 阿里巴巴编码规范(Java)考试地 ...
- hibernate课程 初探单表映射2-6 session详解(下)
本节主要内容: 1 介绍了getCurrentSession和opensession的区别 2 demo:通过打印比较两个session是否相同,验证两个session是否是同一session 3 d ...
- System Center Configuration Manager 2016 域准备篇(Part1)
本系列指南如何从Microsoft安装最新的Configuration Manager基准版本.较新的可用基准版本System Center Configuration Manager(当前分支)版本 ...
- jquery-weui picker组件实现只选择年月
var date = new Date() var month = date.getMonth()+1 //获取当前月份 $('#selectTime').picker({ toolbarTempla ...
- HDU 1712 ACboy needs your help AC男需要你的帮助 (分组的背包)
分组背包问题:有N件物品和一个容量为V的背包.第i件物品的体积是c[i],价值是w[i].这些物品被划分为若干组,每组中的物品互相冲突,最多选一件.求解将哪些物品装入背包可使这些物品的体积总和不超过背 ...
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getSer
这其实就是 获得应用的根url,比如说你的应用的根路径是 http://localhost:8080,那么你列出的代码就是为basePath赋值为 http://localhost:8080.具体点: ...
- 传入指定字段名称就可以排序的EF写法
private static IQueryable<T> SetQueryableOrder<T>(this IQueryable<T> query, string ...
- 说说qwerty、dvorak、colemak三种键盘布局
[qwerty布局] qwerty布局大家应该都很熟悉了,全世界最普及的键盘布局. 截止到去年接触并使用dvorak布局之前,我使用了十几年qwerty布局,在http://speedtest.10f ...