Run ID:100691

提交时间:2024-12-10 20:43:22

def count_bits(n): count_1 = 0 count_0 = 0 while n > 0: if n % 2 == 1: count_1 += 1 else: count_0 += 1 n //= 2 return count_1, count_0 A_count = 0 B_count = 0 for i in range(1, 1001): count_1, count_0 = count_bits(i) if count_1 > count_0: A_count += 1 else: B_count += 1 print(A_count, B_count)