JZOJ 7.11B组第三题 进化序列
来源:互联网 发布:2017手机淘宝店铺装修 编辑:程序博客网 时间:2024/06/10 05:55
题目:
Abathur采集了一系列Primal Zerg 的基因样本,这些基因构成了一个完整的进化链。为了方便,我们用A0,A1...An-1 这n 个正整数描述它们。一个基因Ax 可以进化为序列中在它之后的基因Ay。这个进化的复杂度,等于Ax | Ax+1...| Ay的值,其中| 是二进制或运算。Abathur 认为复杂度小于M 的进化的被认为是温和的。它希望计算出温和的进化的对数。
Input:
4 61 3 5 1output:
2
分析:
此题可以暴力水解。用线段树来维护区间中a[x]xora[x+1]……a[x+100]的值,每隔一百取一波,用来缩短时间。然后如果下一次再多一百便s[y]>m,那么便开始for找到临界点。最后不断inc一下ans即可。
代码:
const
maxn=100000;
var
a,sum:array [0..maxn] of longint;
n,m:longint;
ans:int64;
procedure init;
var
i,j:longint;
begin
readln(n,m);
for i:=1 to n do
read(a[i]);
for i:=1 to n do
begin
sum[i]:=a[i];
for j:=i+1 to i+100 do
sum[i]:=sum[i] or a[j];
end;
end;
procedure main;
var
i,j,section,back:longint;
now:int64;
begin
for i:=1 to n do
begin
now:=0;
section:=i;
if i+100<=n then
while true do
begin
if now or sum[section]>m then
break;
now:=now or sum[section];
inc(section,101);
if section+100>n then
break;
end;
if section>i then
inc(ans,section-i-1);
back:=0;
for j:=section to n do
begin
if now or a[j]>m then
break;
inc(back);
now:=now or a[j];
end;
if back>0 then
if section=i then
inc(ans,back-1)
else
inc(ans,back);
end;
write(ans);
end;
begin
assign(input,'evolve.in');reset(input);
assign(output,'evolve.out');rewrite(output);
init;
main;
close(input);close(output);
end.
- JZOJ 7.11B组第三题 进化序列
- JZOJ 7.10B组第三题 创世纪
- JZOJ 7.9 B组第三题 treecut
- jzoj. 3518. 【NOIP2013模拟11.6A组】进化序列(evolve)
- JZOJ 3518. 【NOIP2013模拟11.6A组】进化序列(evolve)
- JZOJ 4.1 B组 无限序列
- jzoj 3518_进化序列_模拟
- JZOJ 7.11 B组第一题 解题
- jzoj. 3889. 【NOIP2014模拟10.25B组】序列问题
- JZOJ 7.9 B组第二题 blockenemy
- JZOJ 7.9B组
- JZOJ 4.1 B组 俄罗斯方块
- JZOJ 8.7 B组总结
- JZOJ 8.8 B组总结
- JZOJ 8.10 B组总结
- JZOJ 8.14 B组总结
- JZOJ 8.12 B组总结
- JZOJ 8.15 B组总结
- C#客户端(WinForm)自动登录
- 跳转绝对地址
- 使用@Named注解(一个接口多个实现,匹配引入想要的实现类)
- 扎克伯格写给员工的Facebook内部PPT
- EA&UML日拱一卒-活动图::AcceptEventAction
- JZOJ 7.11B组第三题 进化序列
- win7+caffe+cuda8.0+cudnn
- HTML基础知识总结4之table布局
- 输入一个5位数,然后将反序输入(12345 输出54321)
- windows下编译caffe报错:error MSB4062: 未能从程序集 E:\NugetPackages\OpenCV.2.4.10\......的解决办法
- oracle创建存储过程及Job
- jquery parent()和parents()的区别
- CSS基础知识
- Qt5之QWS和QPA