結果
| 問題 | No.118 門松列(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-23 20:56:34 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 166 ms / 5,000 ms |
| コード長 | 414 bytes |
| 記録 | |
| コンパイル時間 | 132 ms |
| コンパイル使用メモリ | 77,336 KB |
| 最終ジャッジ日時 | 2025-12-03 14:44:21 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#!/usr/bin/python
from fractions import Fraction
from collections import Counter
mul = lambda x, y: x*y
nCr = lambda n, r: int(reduce(mul, (Fraction(n-i, i+1) for i in xrange(r)), 1))
mod = int(1e9) + 7
n = int(raw_input())
As = map(int, raw_input().split())
res = nCr(n, 3)
for v in filter(lambda e: e>1, Counter(As).values()):
res -= nCr(v, 2) * (n-v)
if v >= 3:
res -= nCr(v, 3)
print res % mod