結果

問題 No.1072 A Nice XOR Pair
ユーザー umashi-pan-tnokk093n
提出日時 2020-06-06 13:01:06
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,804 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 43,788 KB
最終ジャッジ日時 2024-12-23 12:14:51
合計ジャッジ時間 6,663 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
n,x=map(int,input().split())
a=[]
b=dict()
for i in range(n):
    num=int(input())
    a.append(num)
    if num not in b:
        b[num]=1
    else:
        b[num]+=1

c=list(set(a))
#print(b)
#print(c)
ans=0
if x==0:
    def combinations_count(n, r):
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

    for i in b.values():
        ans+=combinations_count(i,2)
    
else:
    for i in c:
        m=x^i
        if m in b:
            ans+=b[m]*b[i]
    ans=ans//2
print(ans)
0