結果

問題 No.118 門松列(2)
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-04-23 20:56:34
言語 Python2
(2.7.18)
結果
AC  
実行時間 93 ms / 5,000 ms
コード長 414 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 13,964 KB
最終ジャッジ日時 2024-04-17 12:57:23
合計ジャッジ時間 2,731 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
8,192 KB
testcase_01 AC 93 ms
13,964 KB
testcase_02 AC 90 ms
13,652 KB
testcase_03 AC 91 ms
13,876 KB
testcase_04 AC 93 ms
13,948 KB
testcase_05 AC 92 ms
13,936 KB
testcase_06 AC 21 ms
8,064 KB
testcase_07 AC 23 ms
8,064 KB
testcase_08 AC 22 ms
8,064 KB
testcase_09 AC 86 ms
13,612 KB
testcase_10 AC 39 ms
9,088 KB
testcase_11 AC 43 ms
9,472 KB
testcase_12 AC 36 ms
8,960 KB
testcase_13 AC 32 ms
8,448 KB
testcase_14 AC 86 ms
13,524 KB
testcase_15 AC 28 ms
8,192 KB
testcase_16 AC 60 ms
11,220 KB
testcase_17 AC 31 ms
8,448 KB
testcase_18 AC 44 ms
9,728 KB
testcase_19 AC 53 ms
10,752 KB
testcase_20 AC 55 ms
10,880 KB
testcase_21 AC 76 ms
12,492 KB
testcase_22 AC 39 ms
9,344 KB
testcase_23 AC 69 ms
12,248 KB
testcase_24 AC 44 ms
9,856 KB
testcase_25 AC 53 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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
0