Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver dollars; one coin is counterfeit even though its color and size make it indistinguishable from the real silver dollars. The counterfeit coi…
1.链接地址: http://poj.org/problem?id=1013 http://bailian.openjudge.cn/practice/2692 http://bailian.openjudge.cn/practice/1013 2.题目: Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37454   Accepted: 11980 Description Sally…
Counterfeit Dollar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36206   Accepted: 11561 Description Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver dollars; one coin is counterfeit ev…
Sally Jones has a dozen Voyageur silver dollars. However, only eleven of the coins are true silver dollars; one coin is counterfeit even though its color and size make it indistinguishable from the real silver dollars. The counterfeit coin has a diff…
布尔代数上的位运算 布尔代数是一个数学知识体系,它在0和1的二进制值上演化而来的. 我们不需要去彻底的了解这个知识体系,但是里面定义了几种二进制的运算,却是我们在平时的编程过程当中也会遇到的.这四种运算分别是或.与.非和异或.下图展示了在布尔代数的知识体系中,对这四种运算的定义. 从左至右依次是非.与.或以及异或.这个图阐述的是针对一位二进制的运算结果,我们可以将其扩大到N位二进制.比如两个二进制[aw,aw-1...a1]和[bw,bw-1...b1],它们的四种运算则是对两者每一个相对应的位…
题目链接:http://poj.org/problem?id=2777 Description Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds of problems. Here, we get a new problem.  There is a very long board with length L centimeter, L is a…
In the game of Sudoku, you are given a large 9 × 9 grid divided into smaller 3 × 3 subgrids. For example, . 2 7 3 8 . . 1 . . 1 . . . 6 7 3 5 . . . . . . . 2 9 3 . 5 6 9 2 . 8 . . . . . . . . . . . 6 . 1 7 4 5 . 3 6 4 . . . . . . . 9 5 1 8 . . . 7 .…
Description 司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队.一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图.在每一格平原地形上最多可以布置一支炮兵部队 (山地上不能够部署炮兵部队):一支炮兵部队在地图上的攻击范围如图中黑色区域所示: 如果在地图中的灰色所标识的平原上部署一支炮兵部队,则图中的黑色的网格表示它能够攻击到的区域:沿横向左右各两格,沿纵向上下各两格.图上其它白色网格均攻击…
136-只出现过一次的数字 思路:可以考虑到数字以二进制形式存储,当两个不同的数字异或的时候会是true,所以把数组里的数字都一一处理一遍就可以了. class Solution { public: int singleNumber(vector<int>& nums) { int res=0; for(auto num:nums) res^=num; return res; } }; 201-数字范围按位与 思路:m和n每次向右平移一位直到相等为止,记录下平移的次数i,然后让m往左平…
一.位运算实例 1.用一个表达式,判断一个数X是否是2的N次方(2,4,8,16.....),不可用循环语句. X:2,4,8,16转化成二进制是10,100,1000,10000.如果减1则变成01,011,0111,01111.两者做按位与运算,结果如果为0,则X是2的N次方. 2.统计一个整数的二进制中1的个数 int count_number_of_one(int number) { int counter = 0; while (number) { counter++; number…