国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

leetcode python 476

2019-11-08 02:29:08
字體:
來源:轉載
供稿:網友

Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary rePResentation.

Note:

The given integer is guaranteed to fit within the range of a 32-bit signed integer.You could assume no leading zero bit in the integer’s binary representation.

Example 1:

Input: 5Output: 2Explanation: The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.
class Solution(object):    def findComplement(self, num):        """        :type num: int        :rtype: int        """        a = bin(num)        print('%s',a)        b = len(a)-2        print('%d',b)        c = pow(2,b)-1        return num ^ c
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 枞阳县| 大埔县| 石河子市| 洪泽县| 雷山县| 辛集市| 房产| 阿拉尔市| 胶州市| 平原县| 湘西| 渑池县| 连云港市| 古浪县| 四平市| 余干县| 聂拉木县| 兴和县| 庆安县| 阿鲁科尔沁旗| 千阳县| 剑阁县| 石棉县| 温宿县| 黎城县| 彩票| 通许县| 曲靖市| 潜江市| 兴业县| 安国市| 乌拉特中旗| 凌海市| 乌拉特后旗| 蒙自县| 双峰县| 禹州市| 金溪县| 龙口市| 昭平县| 扎囊县|