leetcode326
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的更多相关文章
- LeetCode----326. Power of Three(Java)
package isPowerOfThree326; /* Given an integer, write a function to determine if it is a power of th ...
- 每天一道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 ...
- [python语法巩固][leetcode326][Power of Three]
题目大意: 让你判断一个int是否为3的幂; 最简单的思路 C++ class Solution { public: bool isPowerOfThree(int n) { for(long lon ...
- [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 ...
- leetcode231 2的幂 leetcode342 4的幂 leetcode326 3的幂
1.2的幂 正确写法: class Solution { public: bool isPowerOfTwo(int n) { ) return false; )) == ; } }; 错误写法1: ...
- LeetCode 326
Power of Three Given an integer, write a function to determine if it is a power of three. Follow up: ...
随机推荐
- WC游记
第一次来WC,感觉这种集训真吼啊 day0 火车上快速补习了莫队,和AC自动姬,AC自动姬以前就会写只不过太久没写忘了我会了= = 莫队只是学习了做法,还没有做过题…… 本来想再复习一下后缀数组,然后 ...
- $.ajax()方法详解--极快瑞中的阿贾克斯函数
ajax() 函数和那些abs()函数 sin()这些函数都是底层实现好了,封装好了,可以直接拿来用的 使用者只需要传入参数,然后就可以得到相应的结果 $.ajax({name:value, name ...
- 第一章 spring起步
点击 网址 http://start.spring.io/ 就可以获得spring-boot的项目结构. 如下: 将项目解压到自己的项目中,然后找到mian函数所在启动类.运行.出现: 表示已经运行了 ...
- C#读取Mysql blob字段 (转帖)
http://blog.csdn.net/config_man/article/details/6123191 开发环境:Windows XP Professional SP3.VS2008.Winf ...
- Java static 使用
1. 静态代码块 class H { static{ Sysout.out.println("static block"); } } 静态代码块先与构造函数执行 静态代码块: 静态 ...
- linux中set的用法
功能说明:设置shell.语 法:set [+-abCdefhHklmnpPtuvx]补充说明:用set 命令可以设置各种shell选项或者列 出shell变量.单个选项设置常用的特性.在某些选项之后 ...
- jQuery .tmpl(), .template()学习资料小结
昨晚无意中发现一个有趣的jQuery插件.tmpl(),其文档在这里.官方解释对该插件的说明:将匹配的第一个元素作为模板,render指定的数据,签名如下: .tmpl([data,][options ...
- bzoj2263: Pku3889 Fractal Streets
给出两点编号,求如图所示的图中两点间欧氏距离*10取整 递归处理由编号求出坐标 #include<cstdio> #include<cmath> int T,n,s,t; vo ...
- 建造者模式及C++实现
下面是我自己对建造者模式的理解.具体我还没在开发中应用过,这只是对于书本的理解. 建造者模式 建造者模式:将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示.这是建造者模式的标准 ...
- 使用xmlHttprequest有感
原文地址:http://my.oschina.net/LinBandit/blog/33160 之前一片日志说使用xmlhttprequest获取服务数据时,在IE下能通过而在chrome不能通过的问 ...