poj 3748 位操作
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 8856 | Accepted: 3535 |
Description
Input
Output
Sample Input
12345678,0,3
Sample Output
1234567c
Source
做法一:
C++标准库:bitset 用法整理 :
http://happyboy200032.blog.163.com/blog/static/46903113201291252033712/
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<bitset>//二进制类,bit位,初始为0
using namespace std;
int main(){
int r,x,y;
while(scanf("%x,%d,%d",&r,&x,&y)==){//输入16进制数
bitset<> b(r);
b.reset(x);
b.set(y);
b.set(y-);
b.reset(y-);
printf("%x\n",b.to_ulong());//将二进制转换为unsign long数值
}
return ;
}
做法二:
模拟
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<bitset>
using namespace std;
int bit[];
int main(){
int r,x,y;
while(scanf("%x,%d,%d",&r,&x,&y)==){
memset(bit,false,sizeof(bit));
int i=;
for(;i<;i++){
bit[i]=r&;
r=r>>;
}
bit[x]=;
bit[y]=;
bit[y-]=;
bit[y-]=;
for(i=;i>=;i--){
r=r<<;
r=r|bit[i];
}
printf("%x\n",r);
}
return ;
}
poj 3748 位操作的更多相关文章
- POJ 3748:位操作
位操作 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8964 Accepted: 3581 Description 如 ...
- POJ - 3652 Persistent Bits
“模拟”类型,题型容易,使用bitset库对二进制逐位操作,初始化.十进制转二进制(unsigned int).位操作. POJ - 3652 Persistent Bits Time Limit: ...
- poj 1753 Flip Game 枚举(bfs+状态压缩)
题目:http://poj.org/problem?id=1753 因为粗心错了好多次……,尤其是把1<<15当成了65535: 参考博客:http://www.cnblogs.com/k ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- POJ 1321 棋盘问题(状态压缩DP)
不总结的话, 同一个地方会 WA 到死 思路: 状态压缩 DP. 1. s 表示压缩状态, 若第 i 列放了棋子, 那么该列置 1, 否则该列置 0. 假如 s = 3(0x011) 那么表示棋盘的第 ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
随机推荐
- GridView中合并单元格
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Da ...
- Re:从零开始的Spring Security Oauth2(二)
本文开始从源码的层面,讲解一些Spring Security Oauth2的认证流程.本文较长,适合在空余时间段观看.且涉及了较多的源码,非关键性代码以…代替. 准备工作 首先开启debug信息: l ...
- leetcode 反转字符串
请编写一个函数,其功能是将输入的字符串反转过来. 示例: 输入:s = "hello" 返回:"olleh" /** * @param {string} s * ...
- tomcat异常 Socket bind failed: [730048]
tomcat从官网站点下载时须注意版本信息: zip格式为window压缩版. tar.gz为linux安装板. installer为window安装板. 解压后的各文件功能与作用: bin:用于放置 ...
- linux网络NAT配置方式
NAT访问的权限如下: 外网不可以访问虚拟机,主机和虚拟机可以互访,网络和主机也可以互访: 1.打开虚拟机——编辑——虚拟网络编辑器——. 2. 3.进入虚拟机的linux系统点击网络 4. 5.点击 ...
- Django-05模型层之多表操作2
7.3 多表操作 一.创建模型 实例:我们来假定下面这些概念,字段和关系作者模型:一个作者有姓名和年龄.作者详细模型:把作者的详情放到详情表,包含生日,手机号,家庭住址等信息.作者详情模型和作者模型之 ...
- 线程概要 Java
线程 进程和线程的区别 串行:初期的计算机只能串行执行任务,大量时间等待用户输入 批处理:预先将用户的指令集中成清单,批量串行处理用户指令,仍然无法并发执行 进程:进程独占内存空间,保存各自运行状态, ...
- 一、SecureCRT 8.0 客户端连接服务器
1.通过远程连接服务器linux,连接的是ssh服务: 如图:ssh2协议是ssh的升级版. 连接模式: 2. Ctrl+d 快速退出==exit/quit/logout 3.SecureCRT 改变 ...
- linux 安全配置随笔
1. 禁止Ctrl+Alt+Del直接重启服务器 /bin/mv /etc/init/control-alt-delete.conf /etc/init/control-alt-delete.conf ...
- Easyui里面动态设置输入框的可见性
JQuery EasyUI 动态隐藏 一.隐藏datagrid某一列 $('#dg').datagrid('hideColumn', 'field'); 二.隐藏html的lable.input标 ...