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小的 ...
随机推荐
- Murano简介
Project Mission The mission for this project is to provide a way to make third-party applications an ...
- linux安装gcc和gcc-c++
有些VPS中使用的是精简版Linux,上篇linux下自动备份blog到dropbox中的gcc和gcc-c++编译器没安装,无法编译出链接的"hostid",下面是Linux安装 ...
- js 独立命名空间,私有成员和静态成员
独立的命名空间 1可以避免全局变量污染. 全局变量污染不是 说 被全局变量污染,而是说不会污染全局变量. 2实现私有成员. 在js中函数 就可以满足独立的命名空间的两点需求. 如: ...
- 记DotNetBar换肤
界面: comboBoxEx 选择皮肤 buttonX 测试指定皮肤 styleManager 后台代码: 初始化 : this.EnableGlass = false; 设置窗体效果 不设置 依然 ...
- 电脑没有声音,显示“未插入耳机或扬声器”,检测不到Realtek高清晰音频管理器
2018-7-16,电脑彻夜未关,早上发现已经死机了.关机重启之后,就发现没有声音了,提示“未插入耳机或扬声器”,并且检测不到Realtek高清晰音频管理器,只能检查到显卡音频输出.首先,音箱在其他电 ...
- hibernate课程 初探单表映射2-7 hbm配置文件常用设置
本节主要简介hbm配置文件以下内容: 1 mapping标签 2 class标签 3 id标签 1 hibbernate-mapping标签 schema 模式名称 catalog 目录名称 defa ...
- git 如何生成 SSH 公钥
1.打开你的git bash 窗口 2.进入.ssh目录:cd ~/.ssh 3.找到id_rsa.pub文件:ls 4.查看公钥:cat id_rsa.pub 或者vim id_rsa.pub ...
- mui的ajax例子3
mui.get() 前端页面: <!DOCTYPE html><html><head> <meta charset="utf-8"> ...
- nginx停止后再启动出现: [error] open() "/usr/local/nginx/logs/nginx.pid" failed错误的解决方法
为了备份数据 手动停止了服务器的nginx 结果启动时报错 nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" fail ...
- Linux 下查找指令
原文链接:http://www.cnblogs.com/sunleecn/archive/2011/11/01/2232210.html whereis <程序名称>查找软件的安装路径-b ...