TLE on 714B

Revision en1, by ritik652000, 2021-04-11 22:50:53

Can someone please help me, I got TLE on O(N) on 714B?

mod = 10**9 + 7
for _ in range(int(input())):
    n = int(input())
    arr = list(map(int,input().split()))
    count = arr[0]
    f = 1
    for i in range(1,n):
        count&=arr[i]
        f*=i
    f//=(n-1)
    t = arr.count(count)
    p = 1
    if(t<=1):
        print(0)
    else:
        
        p = t*(t-1)
        re = p*f
        print(re%mod)
Tags #tle, #714, #b

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English ritik652000 2021-04-11 22:50:53 464 Initial revision (published)