結果
問題 | No.118 門松列(2) |
ユーザー |
|
提出日時 | 2015-04-23 20:56:34 |
言語 | Python2 (2.7.18) |
結果 |
AC
|
実行時間 | 90 ms / 5,000 ms |
コード長 | 414 bytes |
コンパイル時間 | 326 ms |
コンパイル使用メモリ | 7,040 KB |
実行使用メモリ | 14,076 KB |
最終ジャッジ日時 | 2024-10-09 06:58:22 |
合計ジャッジ時間 | 2,837 ms |
ジャッジサーバー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