Iam_Sandeep

cf1

Jul 6th, 2023 (edited)
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. # Online Python compiler (interpreter) to run Python online.
  2. # Write Python 3 code in this online editor and run it.
  3. #a=[1,3,5,2]
  4. import sys
  5. import heapq as hq
  6. from functools import reduce
  7.  
  8. input =sys.stdin.readline
  9. t=int(input())
  10. for i in range(t):
  11.     a=input().split()
  12.     for i in range(len(a)):
  13.         a[i]=int(a[i])
  14.  
  15.     tsum=1<<32-1
  16.     for i in a:
  17.         tsum=tsum & i
  18.     print("tsum",tsum)
  19.  
  20.     if tsum>0:
  21.         print(1)
  22.     else:
  23.         ans=0
  24.         n=len(a)
  25.         mask=(1<<32)-1
  26.         for j in range(n):
  27.             mask=mask&a[j]
  28.             if mask==0:
  29.                 ans+=1
  30.                 mask=(1<<32)-1
  31.         print(ans)
  32.  
  33.  
  34.  
  35.  
  36.    
  37.  
  38.    
Advertisement
Add Comment
Please, Sign In to add comment