結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2016-12-17 23:15:42 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 718 bytes |
| コンパイル時間 | 236 ms |
| コンパイル使用メモリ | 82,012 KB |
| 実行使用メモリ | 61,124 KB |
| 最終ジャッジ日時 | 2024-12-14 04:34:57 |
| 合計ジャッジ時間 | 6,748 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 WA * 39 |
ソースコード
#!/usr/bin/env pypy3
# Ref: #138103
import math
P = 10 ** 9 + 7
def bits(n):
return {i for i, b in enumerate(reversed("{:b}".format(n))) if b == '1'}
def solve(n, xs, mod=P):
if not xs:
return math.factorial(n) % mod
ys = sorted(xs)
ans = 1
for y_i, y_j in zip(ys[:-1], ys[1:]):
bs_i = bits(y_i)
bs_j = bits(y_j)
if bs_i <= bs_j:
ans = ans * math.factorial(len(bs_j) - len(bs_i)) & mod
else:
return 0
return ans
def main():
n, k = (int(x) for x in input().split())
if k == 0:
xs = []
else:
xs = [int(x) for x in input().split()]
print(solve(n, xs))
if __name__ == '__main__':
main()
はむ吉🐹