public class Solution {
public bool IsPowerOfThree(int n) {
return n > && ( % n == );
}
}

https://leetcode.com/problems/power-of-three/#/description

使用循环实现,python

 class Solution:
def isPowerOfThree(self, n: int) -> bool:
while n > and n % == :
n = n //
return n ==

leetcode326的更多相关文章

  1. LeetCode----326. Power of Three(Java)

    package isPowerOfThree326; /* Given an integer, write a function to determine if it is a power of th ...

  2. 每天一道LeetCode--326. Power of Three

    Given an integer, write a function to determine if it is a power of three. Follow up:Could you do it ...

  3. [python语法巩固][leetcode326][Power of Three]

    题目大意: 让你判断一个int是否为3的幂; 最简单的思路 C++ class Solution { public: bool isPowerOfThree(int n) { for(long lon ...

  4. [Swift]LeetCode326. 3的幂 | Power of Three

    Given an integer, write a function to determine if it is a power of three. Example 1: Input: 27 Outp ...

  5. leetcode231 2的幂 leetcode342 4的幂 leetcode326 3的幂

    1.2的幂 正确写法: class Solution { public: bool isPowerOfTwo(int n) { ) return false; )) == ; } }; 错误写法1: ...

  6. LeetCode 326

    Power of Three Given an integer, write a function to determine if it is a power of three. Follow up: ...

随机推荐

  1. jsp页面编写锚点,和html页面编写锚点

    html锚点的编写方式,在jsp中不兼容.因此在写动态网页时,需要注意 一:html页面中的锚点编写方式 HTML锚点 <a href="#abc">goto1< ...

  2. All the Apache Streaming Projects: An Exploratory Guide

    The speed at which data is generated, consumed, processed, and analyzed is increasing at an unbeliev ...

  3. C语言面试题4

    第二部分:程序代码评价或者找错 1.下面的代码输出是什么,为什么?void foo(void){    unsigned int a = 6;    int b = -20;    (a+b > ...

  4. Collection与Collections,Array与Arrays的区别

    Collection 和 Collections的区别 Collection 在Java.util下的一个接口,它是各种集合结构的父接口.继承与他的接口主要有Set 和List. Collection ...

  5. 大快DKhadoop开发环境安装常见问题与解决方案

    2018年度国内大数据公司排名50强本月初榜单发布,榜单上看到大快搜索跻身50强,再看看他们做的DKHadoop发行版,的确还是蛮厉害的吧!最起码这款DKHadoop用起来确实在易用性方面要更好!Dk ...

  6. Django 配置总结

    配置 app urls 项目下的urls.py from django.conf.urls import url,include urlpatterns = [ url(r'^BookApp/', i ...

  7. C# 日期格式化的中的(/)正斜杠的问题(与操作系统设置有关)

    Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd" )); //这行代码, 如果你在系统日期格式默认的情况下输出 2013/0 ...

  8. g++编译后中文显示乱码解决方案

    环境:Windows 10 专业版 GCC版本:5.3.0 测试代码: #include <iostream> using namespace std; int main(int argc ...

  9. vue+node+mongoDB前后端分离个人博客(入门向)

    最近学习了VUE,自己为了学习做了个小小的博客,功能很简单,不过开发过程中也遇到了很多坑,所以记录下来方便以后使用.欢迎大家交流学习. 功能 实现了用户注册.登录.token检测登录.用户留言.个人中 ...

  10. 求两点之间距离 C++

    求两点之间距离(20 分) 定义一个Point类,有两个数据成员:x和y, 分别代表x坐标和y坐标,并有若干成员函数. 定义一个函数Distance(), 用于求两点之间的距离.输入格式: 输入有两行 ...