Last active
December 26, 2015 12:38
-
-
Save ranlix/7152199 to your computer and use it in GitHub Desktop.
用于测试手机屏幕在播放某些分辨率的视频的时候的补偿值:
32*x + 2(or 4 or 8 or 16 or 32) = y, 在y输入任意正整数的时候,保证x为有且仅有一个正整数的值
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding=utf-8 -*- | |
def is_int(): | |
inputNum = int(input("Please input a number: ")) | |
#生成补偿值的列表 | |
offset_list = range(1,6) | |
#生成 inputNum-补偿值 列表 | |
new_list = [(inputNum - 2**i)%32 for i in offset_list] | |
#判断 inputNum-补偿值是不是32的倍数 | |
if new_list.count(0) == 1: | |
print "Yes!" | |
print "Offset is " + str(2**offset_list[new_list.index(0)]) | |
else: | |
print "No!" | |
if __name__ == '__main__': | |
is_int() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment