题解 | #游游的除2操作#(Python3)
游游的除2操作
https://www.nowcoder.com/practice/b797f46aa75145a0bbe112099f7cbd18
# 数组长度和数组 n = int(input()) a = list(map(int, input().split())) b, c = dict(), dict() ans = 10**9 # 比较朴素的方法,每个都除2挨个找过去 for i in range(0,n): for j in range(0, 32): if((a[i]>>j)==0): break b[a[i]>>j] = b.get(a[i]>>j,0) + 1 c[a[i]>>j] = c.get(a[i]>>j,0) + j for k, v in b.items(): if(v==n): ans = min(ans, c[k]) print(ans)#15天刷题#