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小的 ...
随机推荐
- 深刻理解Linux进程间通信(IPC)
https://www.ibm.com/developerworks/cn/linux/l-ipc/ linux下进程间通信的几种主要手段简介: 管道(Pipe)及有名管道(named pipe):管 ...
- log(A^B) = BlogA
令 x = logA, y = logB, z=log(AB) .2x = A, 2y = B, 2z = AB, 则有 2z = AB = (2x)^(2y) = 2x(2^y) ,有z = x*2 ...
- ACdream 1427—— Nice Sequence——————【线段树单点更新,区间查询】
Nice Sequence Time Limit: 4000/2000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Su ...
- c#写word文档基础操作(自己控制样式)
下面一个函数,建立一个Word 文档,添加页眉.页脚,在内容中两个不同字体的Hello!!! 来自 <http://bbs.csdn.net/topics/340041961> pub ...
- NGSL + NAWL 单词表 以及学习网站
https://quizlet.com/44769538/nawl-1-1-50-flash-cards/ NAWL 网站 NAWL 单词表 + NGSL 单词表 http://www.newgen ...
- eclipse之插件添加
在ftp.properties文件中,中文出现十六进制显示情况,如下: 解决该问题只需要在eclipse中下载一个插件即可解决, 步骤: help ---> install new softw ...
- Android 超简单的拖动按钮 悬浮按钮 吸附按钮
第一种 第二种 第一种实现方法 xml布局 <RelativeLayout xmlns:android="http://schemas.android.com/apk/re ...
- .gitignore梳理
参考来源: https://www.cnblogs.com/kevingrace/p/5690241.html 对于经常使用Git的朋友来说,.gitignore配置一定不会陌生.废话不说多了,接下来 ...
- PHP snippets
Friendly file size string public static function bytesToSize($bytes) { if ($bytes < 1024) { retur ...
- 有些其他程序设置为从 Outlook 下载并删除邮件。为防止发生此意外情况,我们将这些邮件放入一个特殊的 POP 文件夹中
最近使用FOXMAIL接收MSN邮件时,发现有一些邮件收取不到,进到WEB页面,页面下方提示“你的邮件位于 POP 文件夹中!有些其他程序设置为从 Outlook 下载并删除邮件.为防止发生此意外情况 ...