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

发现一个好帖:

学习一下:

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. 简说mvc路由

    首先我们通过在Global.asax中的Application_Start将路由信息注册到RouteTable的Routes静态属性中.如下代码所示: public class RouteTable ...

  2. layui实现checkbox的目录树tree

    layui.use([ 'tree' ], function() {$ = layui.jquery;form = layui.form;//获取节点数据getTreeData();}); funct ...

  3. 【Leetcode】【Easy】Contains Duplicate

    Given an array of integers, find if the array contains any duplicates. Your function should return t ...

  4. [翻译] MSAlertController

    MSAlertController You can use AlertController in iOS7!! 你可以在iOS中使用AlertController了 MSAlertController ...

  5. Stop-VM

    stop-vm vm01 -force  正常关机,留给Guest 5分钟保存数据,然后关闭 stop-vm vm02 -turnoff 断电关机 Windows Server 2008 R2默认没有 ...

  6. 以太网的 MAC 层

    一.MAC 层的硬件地址 在局域网中,主机的硬件地址又称为物理地址,或 MAC 地址.6个字节. IEEE 的注册管理机构 RA 负责向厂家分配地址字段的前三个字节(即高位 24 位,组织唯一标识符O ...

  7. Programming Assignment 2: Seam Carving

    编程作业二 作业链接:Seam Carving & Checklist 我的代码:SeamCarver.java 问题简介 接缝裁剪(Seam carving),是一个可以针对照片内容做正确缩 ...

  8. 捡了一个非常淫荡的PHP后门,给跪了

    <?php unlink($_SERVER['SCRIPT_FILENAME']); ignore_user_abort(true); set_time_limit(0); $remote_fi ...

  9. 让IE6、7、8兼容@media属性

    通常做页面适配的时候,经常会用到@media属性,对不同屏幕范围内的元素设置不同的样式.但是@media属性不兼容IE8及IE8以下的浏览器 解决方法: 直接在页面中引入respond.src.js即 ...

  10. python Queue在两个地方

    其一: Source code: Lib/queue.py The queue module implements multi-producer, multi-consumer queues. It ...