这里不列举普通的方法了。

发现一个好帖:

学习一下:

https://blog.csdn.net/butterfly5211314/article/details/86099993

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

pyhton的:

#
# @lc app=leetcode.cn id=342 lang=python3
#
# [342] 4的幂
#
# https://leetcode-cn.com/problems/power-of-four/description/
#
# algorithms
# Easy (44.37%)
# Total Accepted: 6.1K
# Total Submissions: 13.8K
# Testcase Example: '16'
#
# 给定一个整数 (32 位有符号整数),请编写一个函数来判断它是否是 4 的幂次方。
#
# 示例 1:
#
# 输入: 16
# 输出: true
#
#
# 示例 2:
#
# 输入: 5
# 输出: false
#
# 进阶:
# 你能不使用循环或者递归来完成本题吗?
#
#
class Solution:
def isPowerOfFour(self, num: int) -> bool:
if num<=0:
return False
return True if pow(4,int(math.log(num,4)))==num else False #使用log函数实现,记住加int

Leecode刷题之旅-C语言/python-342 4的幂的更多相关文章

  1. Leecode刷题之旅-C语言/python-1.两数之和

    开学后忙的焦头烂额(懒得很),正式开始刷leecode的题目了. 想了想c语言是最最基础的语言,虽然有很多其他语言很简单,有更多的函数可以用,但c语言能煅炼下自己的思考能力.python则是最流行的语 ...

  2. Leecode刷题之旅-C语言/python-387 字符串中的第一个唯一字符

    /* * @lc app=leetcode.cn id=387 lang=c * * [387] 字符串中的第一个唯一字符 * * https://leetcode-cn.com/problems/f ...

  3. Leecode刷题之旅-C语言/python-28.实现strstr()

    /* * @lc app=leetcode.cn id=28 lang=c * * [28] 实现strStr() * * https://leetcode-cn.com/problems/imple ...

  4. Leecode刷题之旅-C语言/python-7.整数反转

    /* * @lc app=leetcode.cn id=7 lang=c * * [7] 整数反转 * * https://leetcode-cn.com/problems/reverse-integ ...

  5. Leecode刷题之旅-C语言/python-434 字符串中的单词数

    /* * @lc app=leetcode.cn id=434 lang=c * * [434] 字符串中的单词数 * * https://leetcode-cn.com/problems/numbe ...

  6. Leecode刷题之旅-C语言/python-326 3的幂

    /* * @lc app=leetcode.cn id=326 lang=c * * [326] 3的幂 * * https://leetcode-cn.com/problems/power-of-t ...

  7. Leecode刷题之旅-C语言/python-263丑数

    /* * @lc app=leetcode.cn id=263 lang=c * * [263] 丑数 * * https://leetcode-cn.com/problems/ugly-number ...

  8. Leecode刷题之旅-C语言/python-383赎金信

    /* * @lc app=leetcode.cn id=383 lang=c * * [383] 赎金信 * * https://leetcode-cn.com/problems/ransom-not ...

  9. Leecode刷题之旅-C语言/python-349两整数之和

    /* * @lc app=leetcode.cn id=371 lang=c * * [371] 两整数之和 * * https://leetcode-cn.com/problems/sum-of-t ...

  10. Leecode刷题之旅-C语言/python-349两个数组的交集

    /* * @lc app=leetcode.cn id=349 lang=c * * [349] 两个数组的交集 * * https://leetcode-cn.com/problems/inters ...

随机推荐

  1. ASP.NET Core 上传多文件 超简单教程

    示例源码下载地址 https://qcloud.coding.net/api/project/3915794/files/4463836/download 项目地址 https://dev.tence ...

  2. Scala高阶函数

    1.作为参数的函数 函数可以作为一个参数传入到一个方法当中去 def main(args: Array[String]): Unit = { val myFunc1 =(x:Int) =>{ x ...

  3. VS2013打开项目 提示Asp.net4.5未在web服务器上注册 F5运行 启动不来 权限

    打一个补丁 http://blogs.msdn.com/b/webdev/archive/2014/11/11/dialog-box-may-be-displayed-to-users-when-op ...

  4. 激活pycharm

    1. 修改hosts文件: 添加下面一行到hosts文件,目的是屏蔽掉Pycharm对激活码的验证**0.0.0.0 account.jetbrains.com ** windwos系统hosts文件 ...

  5. SoapUI这么好,舍得不用吗?

    之前尝试去学习哈SoapUI, 安装都报错,直接拖黑不用,对java开发的产品本身不感冒 后来工作上,和老外沟通,发现他们不会用xmlspy,只会SoapUI,心里都想,不学习看来不方便,然后都安装了 ...

  6. UVa 1515 - Pool construction(最小割)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  7. programming-languages学习笔记--第7部分

    programming-languages学习笔记–第7部分 */--> pre.src {background-color: #292b2e; color: #b2b2b2;} pre.src ...

  8. 20165302 学习基础和C语言基础调查

    学习基础和C语言基础调查 ====== 一,技能学习经验体会 要问我有什么技能比大多数人强,这个我还真的不敢说,虽然我在很多方面都有自己的一些了解,比如乐器和绘画,但也都是一知半解,并没有在某一方面出 ...

  9. win2003 HookPort 服务启动失败的解决办法!

    Win2003系统每次开机启动时都弹出个对话框报HookPort 服务启动失败,很多网友都遇到同类问题,问题根源是360安全卫士引起的,官方一直没有给出解决方案 问题描述:Win2003系统每次开机启 ...

  10. Eclipse配置多个Tomcat服务器

    我们在开发大型web项目时,经常需要在eclipse中同时启动多个tomcat服务器来开启多个服务.这里讲解一下如何在eclipse中配置多个tomcat服务器. 配置步骤 1. 在tomcat官网( ...