当前位置:网站首页>Baidu interview question - judge whether a positive integer is to the power of K of 2
Baidu interview question - judge whether a positive integer is to the power of K of 2
2022-07-24 20:43:00 【Chen Yikang】
The code is as follows :
import java.util.Scanner;
public class test{
// Determine whether a positive integer is 2 Of K Power
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int input = scanner.nextInt();
if((input & (input - 1)) == 0){
System.out.println("Yes!");
}
else{
System.out.println("No!");
}
}
}analysis :

边栏推荐
- [leetcode] 1184. Distance between bus stops
- The maximum number of expressions in ora-01795 list is 1000
- [training Day9] rotate [violence] [thinking]
- Failed to create a concurrent index, leaving an invalid index. How to find it
- Flink window & time principle
- OpenGL (1) vertex buffer
- [JVM] selection of garbage collector
- Home Assistant中接入博联WiFi智能遥控
- Native applets are introduced using vant webapp
- Alibaba Sentinel 基操
猜你喜欢

Fluoronisin peptide nucleic acid oligomer complex | regular active group alkyne, SH thiol alkynyl modified peptide nucleic acid
![[FreeRTOS] 10 event flag group](/img/c3/9f9c2ac4641f478575d48afd580b4b.png)
[FreeRTOS] 10 event flag group

Leetcode 1911. maximum subsequence alternating sum

Alibaba sentinel basic operation

Let's make a nice monthly temperature map of China with ArcGIS

Lua environment configuration

What does software testing need to learn?

Huawei set up login with account and password

A simple method of converting SVG to PDF
![[feature construction] construction method of features](/img/5c/c240d9d742f37cbc52afecf15b2ad1.png)
[feature construction] construction method of features
随机推荐
[msp430g2553] graphical development notes (1) configuration environment
[training Day9] maze [line segment tree]
How to learn automated testing
A simple method of converting SVG to PDF
[training Day8] series [matrix multiplication]
Appium element positioning - App automated testing
[advanced data mining technology] Introduction to advanced data mining technology
How to set the allure test report
[feature transformation] feature transformation is to ensure small information loss but high-quality prediction results.
High soft course summary
Each blogger needs to ask himself seven basic questions
[training Day8] tent [mathematics] [DP]
147 set whether to cache by using the routing meta information - use of include and exclude - use of activated and deactivated
The difference between map and flatmap in stream
Flink window & time principle
Easy to use office network optimization tool onedns
Career development suggestions shared by ten CIOs
OpenGL (1) vertex buffer
Login Huawei device in SSH mode
Press Ctrl to pop up a dialog box. How to close this dialog box?