-------------------------------------------------------------

如果一个数的质因子只包括2,3,5,那么这个数n可以表示为:
n=2x+3y+5z

AC代码:

import java.math.BigInteger;

public class Solution {

    public boolean isUgly(int n) {
if(n<1) return false;
while(n%2==0) n/=2;
while(n%3==0) n/=3;
while(n%5==0) n/=5;
return n==1;
} }

题目来源: https://leetcode.com/problems/ugly-number/

LeetCode之263. Ugly Number的更多相关文章

  1. 【一天一道LeetCode】#263. Ugly Number

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 Write a ...

  2. 【LeetCode】263. Ugly Number 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 除去2,3,5因子 日期 [LeetCode] 题目 ...

  3. 【LeetCode】263. Ugly Number

    Ugly Number Write a program to check whether a given number is an ugly number. Ugly numbers are posi ...

  4. leetcode 263. Ugly Number 、264. Ugly Number II 、313. Super Ugly Number 、204. Count Primes

    263. Ugly Number 注意:1.小于等于0都不属于丑数 2.while循环的判断不是num >= 0, 而是能被2 .3.5整除,即能被整除才去除这些数 class Solution ...

  5. LN : leetcode 263 Ugly Number

    lc 263 Ugly Number lc 263 Ugly Number Write a program to check whether a given number is an ugly num ...

  6. [LeetCode] 313. Super Ugly Number 超级丑陋数

    Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all ...

  7. 263. Ugly Number(C++)

    263. Ugly Number Write a program to check whether a given number is an ugly number. Ugly numbers are ...

  8. [LeetCode] 263. Ugly Number 丑陋数

    Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers ...

  9. LeetCode 263 Ugly Number

    Problem: Write a program to check whether a given number is an ugly number. Ugly numbers are positiv ...

随机推荐

  1. [虚拟机]Virtual Box的使用--共享文件夹

    最近为系统测试使用了虚拟机,VM太卡,所以使用了VBox,运行效果还不错 为了主机和客户机之前方便进行数据传输,一般采用文件夹共享的方式(当然,可以直接拖拽) 1,直接拖拽,需要做如下设置 主要的是“ ...

  2. 面对bug和困难的心态

    遇到bug了? 作为程序员,会面对各种各样的bug,我们在编写代码的时候,也是生产bug的过程.在公司总会遇到老同事留下的代码,这些代码出现问题了该怎么办?最常见的想法就是, 老同事怎么考虑这么不周到 ...

  3. Summary - SNMP Tutorial

    30.13 Summary Network management protocols allow a manager to monitor and control routers and hosts. ...

  4. AngularJS版本下载

    大家可以从下面地址获取AngularJS所以版本: https://code.angularjs.org/

  5. Swift与OC区别

    一.Swift与OC区别: 1.swift程序的入口是UIApplicationMain; 2.OC的类是以.h和.m组成的;swift是一.swift结尾的; 3.OC的类是以@interface和 ...

  6. beaglebone black 安装QNX过程

    首先去http://community.qnx.com/sf/go/projects.bsp/frs.texas_instruments_am335_beaglebo 把下面4个下载下来.

  7. 写一个适应所有环境的js模块

    说下背景: 在ES6以前,JS语言没有模块化,如何让JS不止运行在浏览器,且能更有效的管理代码, 于是应运而生CommonJS这种规范,定义了三个全局变量: require,exports,modul ...

  8. Ubuntu虚拟机中断后重启网络断接错误解决方案

    因为该死的windows自动更新,所以vmplayer经常会被强制关闭. 但重新启动后,会发生不能连接到网络的情况显示: waiting for the network configuration…… ...

  9. 对AutoIt中控件和窗口的理解

    经过尝试,对AutoIt中Control和Window有了新的认识,分享一下 1.Control 现在我想对一个WinForm架构的应用程序进行自动化操作,得到控件Advanced Mode属性为[N ...

  10. 利用Levenshtein Distance (编辑距离)实现文档相似度计算

    1.首先将word文档解压缩为zip /** * 修改后缀名 */ public static String reName(String path){ File file=new File(path) ...