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 ...
随机推荐
- .net 异步函数 Async await
.net 异步函数 Async await 一旦为函数添加async关键字 该函数就是一个异步函数. 异步方法必须返回 void 或 Task<> 类型. public static ...
- 曲苑杂坛--查看CPU配置
--===================================================--查看CPU配置SELECT cpu_count AS [Logical CPU Coun ...
- Hadoop 文件命令
* 文件操作 * 查看目录文件 * $ hadoop dfs -ls /user/cl * * 创建文件目录 * $ hadoop dfs -mkdir /user/cl/temp * * 删除文件 ...
- 9w5:第九周程序填空题1
描述 下面的程序输出结果是: 1 2 6 7 8 9 请填空: #include <iostream> #include <iterator> #include <set ...
- OCP换题库了,052新加的考题及答案整理-第16题
16.Your database Is configured In archivelog mode. The USERS01 tablespace Is currently online. You a ...
- linux awk 文本分析实例 [视频]
实例: 点我打开哔哩哔哩 实战: 点我打开哔哩哔哩 以下是一个分享: ➜ log Time Now 16:23:35 > awk '/Installed/' yum.log* | awk -F ...
- The server of Nginx(三)——Nginx企业级优化
相信看过我之前apache文章的朋友们,对服务优化也有了一个大概的了解,相比较而言,Nginx企业中应用的更多一些,因此今天也会详细阐述Nginx的优化,有人说,服务器不需要优化,开虚拟化,分分钟成倍 ...
- 干掉Vivado幺蛾子(2)-- 快速替换debug probes
目录 1. 什么是ECO 2. 操作步骤 参考文献: 我们做项目,进入找bug阶段时,需要用ILA捕获相关的信号.之前我做项目,每改动一次探针(debug probes),都要重新综合.实现,通常要花 ...
- JAVA static深入了解
static关键字: 1)static修饰的成员变量和成员方法独立于该类的任何对象.也就是说,它不依赖类特定的实例,被类的所有实例共享:2)只要这个类被加载,Java虚拟机就能根据类名在运行时数据区的 ...
- Vue页面加载时,触发某个函数的方法
需要在加载页面的时候调用生成验证码的click事件函数 解决方法如下,利用Vue中的mounted mounted:function(){ this.createcode();//需要触发的函数 } ...