当前位置:网站首页>Power of leetcode-4 - simple
Power of leetcode-4 - simple
2022-06-13 05:47:00 【AnWenRen】
title :342 4 The power of - Simple
subject
Given an integer , Write a function to determine if it is 4 Power square . If it is , return true ; otherwise , return false .
Integers n yes 4 To the power of : There are integers x bring n == 4x
Example 1
Input :n = 16
Output :true
Example 2
Input :n = 5
Output :false
Example 3
Input :n = 1
Output :true
Tips
-231 <= n <= 231 - 1
Code Java
public boolean isPowerOfFour(int n) {
if (n == 1 || n == 4)
return true;
if (n < 4)
return false;
int a = (n - 1) & n; // Determine whether it is 2 The power of
if (a == 0){
if (Math.sqrt(n) % 4 == 0) // yes 2 The power of ,4^x The prescription is 2^x
return true;
else
return false;
}
else
return false;
}
边栏推荐
- August 15, 2021 another week
- Database design
- 18 flowable task manualtask and receivetask
- OpenGL Mosaic (8)
- Calculate the number of days between two times (supports cross month and cross year)
- Anaconda configuring the mirror source
- Basic application of sentinel series
- Building a stand-alone version of Nacos series
- Exception after repeated application redeployment on tongweb: application instance has been stopped already or outofmemoryerror:metaspace
- Timeout thread log for tongweb
猜你喜欢
How slow is the application system on tongweb? How dead is it?
How to view tongweb logs correctly?
Quartz database storage
Automatic database backup (using Navicat)
Solution to prompt "permission is required to perform this operation" (file cannot be deleted) when win10 deletes a file
零拷贝技术
Why do so many people hate a-spice
MySQL main query and sub query
MySQL log management and master-slave replication
Four shardingsphere JDBC sharding strategies
随机推荐
Quartz database storage
Sentinel series introduction to service flow restriction
Some methods of string
Tongweb card, tongweb card, tongweb card
Mysql database backup and restore:
C calls the API and parses the returned JSON string
11 signalthrowingevent and signalboundaryevent of flowable signal event
Etcd fast cluster building
Mobile end adaptation scheme
OpenGL Mosaic (8)
20 flowable container (event sub process, things, sub process, pool and pool)
Mongodb multi field aggregation group by
MongoDB 多字段聚合Group by
2021.9.30学习日志-postman
ffmpeg 下载后缀为.m3u8的视频文件
Vagrant virtual machine installation, disk expansion and LAN access tutorial
ZABBIX proxy, sender (without agent monitoring), performance optimization
Config server configuration center of Nacos series
Input a number and output each digit from high to low
Validation set: ‘flowable-executable-process‘ | Problem: ‘flowable-servicetask-missing-implementatio