bzoj3668
noi水题,直接推出来每一位上取什么值才能取1
直接搞就可以了
var a,b:array[..] of longint;
x,n,i,j,k,t,m,ans:longint;
fl:boolean;
s:string;
ch:char; procedure doit(x:longint);
begin
fillchar(b,sizeof(b),);
m:=;
while x<> do
begin
inc(m);
b[m]:=x mod ;
x:=x shr ;
end;
end; begin
readln(n,k);
t:=;
for i:= to do
a[i]:=;
for i:= to n do
begin
s:='';
read(ch);
while ch<>' ' do
begin
s:=s+ch;
read(ch);
end;
readln(x);
doit(x);
if s='OR' then //表示这一位取什么值都能使ans这位上取1,-表示去什么都不可以,表示取1才可以,表示取0才可以
begin
for j:= to do
if b[j]= then a[j]:=;
end
else if s='AND' then
begin
for j:= to do
if b[j]= then a[j]:=-;
end
else begin
for j:= to do
if b[j]= then
begin
if a[j]=- then a[j]:=
else if a[j]= then a[j]:=-
else if a[j]= then a[j]:=
else if a[j]= then a[j]:=;
end;
end;
end;
doit(k);
ans:=;
fl:=false; //fl判断高位是否已经严格小于了
for i:= downto do
if fl then
begin
if a[i]<>- then
ans:=ans+ shl (i-);
end
else begin
if (b[i]=) and ((a[i]=) or (a[i]=)) then ans:=ans+ shl (i-);
if (b[i]=) then
begin
if (a[i]=) or (a[i]=) then
begin
fl:=true;
ans:=ans+ shl (i-);
end
else if a[i]=- then fl:=true
else ans:=ans+ shl (i-);
end;
end; writeln(ans);
end.
bzoj3668的更多相关文章
- [bzoj3668][Noi2014]起床困难综合症_暴力
起床困难综合征 bzoj-3668 Noi-2014 题目大意:题目链接. 注释:略. 想法:Noi考这题...联赛T1难度.... 我们将每个门上的数二进制拆分. 发现:当前位的操作可能直接确定了当 ...
- BZOJ-3668 起床困难综合症 位运算+贪心
faebdc学长杂题选讲中的题目...还是蛮简单的...位运算写的不熟练... 3668: [Noi2014]起床困难综合症 Time Limit: 10 Sec Memory Limit: 512 ...
- bzoj3668: [Noi2014]起床困难综合症
从高位到低位枚举期望的应该是ans最高位尽量取一.如果该数最高位为o的话能够取得1直接更新ans否则判断该位取1是否会爆m不会的话就加上. #include<cstdio> #includ ...
- [BZOJ3668] [Noi2014] 起床困难综合症 (贪心)
Description 21 世纪,许多人得了一种奇怪的病:起床困难综合症,其临床表现为:起床难,起床后精神不佳.作为一名青春阳光好少年,atm 一直坚持与起床困难综合症作斗争.通过研究相关文献,他找 ...
- [bzoj3668][Noi2014]起床困难综合症/[洛谷3613]睡觉困难综合症
来自FallDream的博客,未经允许,请勿转载,谢谢. 21 世纪,许多人得了一种奇怪的病:起床困难综合症,其临床表现为:起床难,起床后精神不佳.作为一名青春阳光好少年,atm 一直坚持与起床困难综 ...
- 【BZOJ3668】【NOI2014】起床困难综合症(贪心)
[NOI2014]起床困难综合症(贪心) 题面 Description 21 世纪,许多人得了一种奇怪的病:起床困难综合症,其临床表现为:起床难,起床后精神不佳.作为一名青春阳光好少年,atm 一直坚 ...
- bzoj千题计划238:bzoj3668: [Noi2014]起床困难综合症
http://www.lydsy.com/JudgeOnline/problem.php?id=3668 这..一位一位的来就好了呀 #include<cstdio> #include&l ...
- bzoj3668 起床困难综合症
Description 21 世纪,许多人得了一种奇怪的病:起床困难综合症,其临床表现为:起床难,起床后精神不佳.作为一名青春阳光好少年,atm 一直坚持与起床困难综合症作斗争.通过研究相关文献,他找 ...
- 刷题向》一道关于位运算的神题(BZOJ3668)(HARD-)
个人觉得这道题对于位运算的加深理解很有意义 根据题目所说,我们要求出一个在给定范围里的自变量,使得最终结果最大. 那么因为这道题是针对于位运算的,所以可以想到用对于位运算取极限情况,即对于“0”和“( ...
随机推荐
- ios中图片的绘画和截图
ios中图片的绘画和截图 CGImageCreateWithImageInRect截图和UIGraphicsGetImageFromCurrentImageContext绘画图片 使用CGImageC ...
- U盘安装centos 6.4教程(总算是弄好了
参考:http://blog.chinaunix.net/uid-27666459-id-3342477.html http://www.linuxidc.com/Linux/2011-05/3569 ...
- Android(java)学习笔记206:利用开源SmartImageView优化网易新闻RSS客户端
1.我们自己编写的SmartImageView会有很多漏洞,但是我们幸运的可以在网上利用开源项目的,开源项目中有很多成熟的代码,比如SmartImageView都编写的很成熟的 国内我们经常用到htt ...
- Unity3D GUI学习之GUI窗口的使用
GUI还可以定义一个窗口,在窗口里面进行控件的添加: using UnityEngine; using System.Collections; public class getbutton : Mon ...
- Array,ArrayList 和 List<T>的选择和性能比较.
Array Class Provides methods for creating, manipulating, searching, and sorting arrays, thereby serv ...
- C# Activator.CreateInstance()
C#在类工厂中动态创建类的实例,所使用的方法为: 1. Activator.CreateInstance (Type) 2. Activator.CreateInstance (Type, Objec ...
- Android Parcelable Trans byte[]
思路: http://stackoverflow.com/questions/10898116/make-custom-parcelable-containing-byte-array 谢谢, 这位外 ...
- KAFKA分布式消息系统[转]
KAFKA分布式消息系统 转自:http://blog.chinaunix.net/uid-20196318-id-2420884.html Kafka[1]是linkedin用于日志处理的分布式消 ...
- 文字排版--粗体(font-weight)
我们还可以使用css样式来改变文字的样式:粗体.斜体.下划线.删除线,可以使用下面代码实现设置文字以粗体样式显示出来. p span{font-weight:bold;} 在这里大家可以看到,如果想为 ...
- (JAVA)从零开始之--打印流PrintStream记录日志文件
这里的记录日志是利用打印流来实现的. 文本信息中的内容为String类型.而像文件中写入数据,我们经常用到的还有文件输出流对象FileOutputStream. File file = new Fil ...