Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
71554 | 胡海峰老师 | 二进制数问题 | Python3 | Accepted | 35 MS | 3756 KB | 390 | 2024-04-25 20:03:51 |
def judge_AB(n): #integer 整数 ones,zeros = 0,0 while n: #非0为True 0为False b = n%2 if b==1: ones +=1 else: zeros +=1 n = n//2 return ones>zeros #True:A类 False: B类 a,b =0,0 for num in range(1,1001): res = judge_AB(num) if res: a+=1 else: b+=1 print(a,b)