【LeetCode】263. Ugly Number
Ugly Number
Write a program to check whether a given number is an ugly number.
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5
. For example, 6, 8
are ugly while 14
is not ugly since it includes another prime factor 7
.
Note that 1
is typically treated as an ugly number.
Credits:
Special thanks to @jianchao.li.fighter for adding this problem and creating all test cases.
按定义做。
class Solution {
public:
bool isUgly(int num) {
if(num <= )
return false; while(num % == )
num /= ;
while(num % == )
num /= ;
while(num % == )
num /= ; return num == ;
}
};
【LeetCode】263. Ugly Number的更多相关文章
- 【LeetCode】263. Ugly Number 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 除去2,3,5因子 日期 [LeetCode] 题目 ...
- 【一天一道LeetCode】#263. Ugly Number
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Write a ...
- 【LeetCode】264. Ugly Number II 解题报告(Java & Python)
标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ https://leetcode.com/prob ...
- 【LeetCode】264. Ugly Number II
Ugly Number II Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose ...
- 【Leetcode】264. Ugly Number II ,丑数
原题 Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime facto ...
- 【leetcode】1201. Ugly Number III
题目如下: Write a program to find the n-th ugly number. Ugly numbers are positive integers which are div ...
- 【easy】263. Ugly Number 判断丑数
class Solution { public: bool isUgly(int num) { ) return false; ) return true; && num % == ) ...
- 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...
- 【LeetCode】137. Single Number II 解题报告(Python)
[LeetCode]137. Single Number II 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/single- ...
随机推荐
- 【动态规划】bzoj1664 [Usaco2006 Open]County Fair Events 参加节日庆祝
将区间按左端点排序. f(i)=max{f(j)+1}(p[j].x+p[j].y<=p[i].x && j<i) #include<cstdio> #incl ...
- JS判断手机访问跳转到手机站
这里提供了六种让手机端访问网站跳转到手机端的方法: 第一种: <script> if(navigator.platform.indexOf('Win32')!=-1){ //pc //wi ...
- 完全背包问题:湫湫系列故事――减肥记I(HDU 4508)
湫湫系列故事――减肥记I HDU 4508 一道裸的完全背包 #include<iostream> #include<algorithm> #include<stdio ...
- 关于ucosII系统的软件系统裁剪性
ucosII是依靠编译时的条件编译来实现软件系统的裁剪性的,即把用户可裁剪的代码段写在#if和#endif预编译指令之间,在编译时根据#if预编译指令后面的常数的值来确定是否该代码段进行编译.在工程文 ...
- entlib验证组件
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 深入浅出话VC++(3)——VC++实现绘图操作
VC++实现绘图操作,说白了也就是对API熟练操作了,下面介绍几种绘图 1. 绘制线条 具体实现代码如下: // 鼠标左键按下时的处理函数 void CDrawView::OnLButtonDown( ...
- JSLint JavaScript代码质量审查工具汉化中文版隆重发布
JSLint是一款JavaScript代码质量审查工具,它可以指出代码中错误.不规范的地方,非常之严格,甚至多写一个空格都会发出警告. JSLint的审查规则,根据众多前辈多年编程经验而写,字字珠玑, ...
- Hibernate各种主键生成器策略与配置详解(转载)
http://www.cnblogs.com/kakafra/archive/2012/09/16/2687569.html 1.assigned 主键由外部程序负责生成,在 save() 之前必须指 ...
- paip.cache 缓存架构以及性能提升总结
paip.cache 缓存架构以及性能提升总结 1 缓存架构以及性能(贯穿读出式(LookThrough) 旁路读出式(LookAside) 写穿式(WriteThrough) 回写式 ...
- IOS设计模式浅析之简单工厂模式(SimpleFactory)
概述 首先说明一下,简单工厂模式不属于23种GOF设计模式之一.它也称作静态工厂方法模式,是工厂方法模式的特殊实现.这里对简单工厂模式进行介绍,是为本系列后面的工厂方法和抽象工厂模式做一个引子. 定义 ...