- 博客(5)
- 收藏
- 关注
原创 P1028 数的计算
我们要求找出具有下列性质数的个数(包含输入的自然数n):先输入一个自然数n(n1.不作任何处理;2.在它的左边加上一个自然数,但该自然数不能超过原数的一半;3.加上数后,继续按此规则进行处理,直到不能再加自然数为止.输入输出格式输入格式:一个自然数n(n输出格式:一个整数,表示具有该性质数的个数。
2017-02-27 21:56:22 867
原创 Number Complement
Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guaranteed to fit within the range of
2017-02-26 19:50:34 226
原创 461 Hamming distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note:0 ≤ x, y
2017-02-26 13:11:19 260
原创 按位异或运算
& 按位与| 按位或^ 按位异或为什么5 & 3得到1;5 | 3得到7;5 ^ 3得到6.. 按位与运算 按位与运算符"&"是双目运算符。其功能是参与运算的两数各对应的二进位相与。只有对应的两个二进位均为1时,结果位才为1 ,否则为0。参与运算的数以补码方式出现。例如:9&5可写算式如下: 00001001 (9的二进制补码)&00000101 (5的二进制补码) 0000000
2017-02-24 17:43:39 4203
原创 最大公约数算法
1、连续整数检测法。#includeusing namespace std;int goc(int m, int n){ int t; if (m>n) t = n; else t = m; while (t) { if (m%t == 0 && n%t == 0) { break; } else t = t - 1; } return t;
2017-02-23 13:37:38 532
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人