LeetCode每日一题——231. Power of Two
来源:互联网 发布:如何看待奚梦瑶 知乎 编辑:程序博客网 时间:2024/06/06 10:49
原题地址:
https://leetcode.com/problems/power-of-two/
Fizz Buzz
描述:
Given an integer, write a function to determine if it is a power of two.
无解题思路:
判断是否是2的次方数,并进行di'gu
作答:
//判断2的次方数public class PowerofTwo {public static void main(String[] args) {for (int i = 0; i < 1000; i++) {if (isPowerOfTwo(i)) {System.out.println(i);} }}static int num = 0;public static boolean isPowerOfTwo(double n) { if (Math.pow(2, num) == n) { num = 0;return true;} else if (Math.pow(2, num) < n) {num++;return isPowerOfTwo(n);} else { num = 0;return false;} }}
1 0
- LeetCode每日一题——231. Power of Two
- leetcode 每日一题 231. Power of Two 326. Power of Three
- Leetcode——231. Power of Two
- leetcode:231 Power of Two-每日编程第十八题
- [leetcode] 231.Power of Two
- LeetCode ||231. Power of Two
- [LeetCode]231.Power of Two
- Leetcode 231. Power of Two
- leetcode 231. Power of Two
- 231. Power of Two LeetCode
- [LeetCode]231. Power of Two
- [LeetCode]231. Power of Two
- LeetCode 231. Power of Two
- [leetcode] 231. Power of Two
- leetcode 231. Power of Two
- LeetCode *** 231. Power of Two
- leetcode 231. Power of Two
- LeetCode 231. Power of Two
- 数据结构期末总结
- Git综述
- Ubuntu 14.04 ROS android
- Nginx+uWSGI+Django在Ubuntu下的部署
- 面试题目详解
- LeetCode每日一题——231. Power of Two
- mysqlbinlog 导出操作日志
- 观察者模式
- FastStone Capture 注册码
- UITextFiedl 左侧设置小图标 leftview
- 1212小结
- Hadoop源码学习-运行实例
- [编程题]删除字符串中出现次数最少的字符
- TensorFlow简介