leetcode刷题,总结,记录,备忘 263
来源:互联网 发布:软件测试方法和技术 编辑:程序博客网 时间:2024/06/04 01:28
leetcode263 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 <= 0) { return false; } if (num == 1) { return true; } while (num != 1) { if (num % 2 == 0) { num /= 2; continue; } if (num % 3 == 0) { num /= 3; continue; } if (num % 5 ==0) { num /= 5; continue; } return false; } return true; }};最后别忘,负数和0的情况,我有几次提交没过就是因为这些。。
0 0
- leetcode刷题,总结,记录,备忘 263
- leetcode刷题。总结,记录,备忘 104
- leetcode刷题。总结,记录,备忘 100
- leetcode刷题。总结,记录,备忘 191
- leetcode刷题。总结,记录,备忘。168
- leetcode刷题, 总结,记录,备忘 171
- leetcode刷题 ,总结,记录,备忘。144
- leetcode刷题,总结,记录, 备忘 141
- leetcode刷题,总结,记录,备忘。116
- leetcode刷题,总结,记录,备忘。96
- leetcode刷题。记录,总结,备忘。217
- leetcode 刷题, 总结,记录,备忘 35
- leetcode刷题,总结,记录,备忘 226
- leetcode刷题,总结,记录,备忘 169
- leetcode刷题,总结,记录,备忘137
- leetcode刷题,总结,记录,备忘83
- leetcode刷题,总结,记录,备忘70
- leetcode刷题,总结,记录,备忘 108
- 诡异事件之电脑连wifi时狂跑流量
- 我的团队管理经验
- ..
- 跨行清算系统的实现原理
- HashMap详解
- leetcode刷题,总结,记录,备忘 263
- 黑马程序员__java基础__数组
- MFC更改对话框的图标以及光标
- Objective-C 基础知识之(六):NSArray、NSMutableArray
- apktool升级:删除~/Library/apktool/framework/1.apk
- 第四章 Transact-SQL 语言基础
- java 自定义对话框
- Activity Manager Service总结
- 使用GCD创建多线程