![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
----------其他
ax_hacker
网络,redhat,信息安全,c++,opengl
展开
-
丑数
题目把只包含因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。思路所谓的一个数m是另一个数n的因子,是指n能被m整除,也就是n%m==0。根据丑数的定义,丑数只能被2、3和5整除。根据丑数的定义,丑数应该是另一个丑数乘以2、3或者5的结果(1除外)。因此我们可以创建一...转载 2018-07-17 16:41:01 · 536 阅读 · 0 评论 -
二进制中1的个数
常规解法:#include <iostream>using namespace std;class Solution {public: int byteCountOne(int n) { int count = 0; //unsigned int flag = 1; while (n) { if (n & 1) count++;...原创 2018-07-18 10:21:34 · 138 阅读 · 0 评论 -
1-n求和 --- 比较a b大小
题目 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。一、利用逻辑与&&的短路条件,递归实现#include <iostream>using namespace std;class Solution {public: int Sum_Solut...原创 2018-07-18 11:21:41 · 688 阅读 · 0 评论