結果

問題 No.118 門松列(2)
ユーザー takakintakakin
提出日時 2020-05-22 00:18:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 167 ms / 5,000 ms
コード長 558 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 16,604 KB
最終ジャッジ日時 2024-04-10 09:04:39
合計ジャッジ時間 4,949 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 163 ms
16,604 KB
testcase_02 AC 164 ms
16,420 KB
testcase_03 AC 165 ms
16,516 KB
testcase_04 AC 158 ms
16,576 KB
testcase_05 AC 155 ms
16,572 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 25 ms
10,624 KB
testcase_08 AC 28 ms
10,752 KB
testcase_09 AC 167 ms
16,256 KB
testcase_10 AC 120 ms
11,904 KB
testcase_11 AC 128 ms
12,288 KB
testcase_12 AC 118 ms
11,520 KB
testcase_13 AC 124 ms
11,136 KB
testcase_14 AC 154 ms
16,168 KB
testcase_15 AC 123 ms
10,880 KB
testcase_16 AC 148 ms
13,940 KB
testcase_17 AC 129 ms
11,136 KB
testcase_18 AC 134 ms
12,416 KB
testcase_19 AC 134 ms
13,264 KB
testcase_20 AC 137 ms
13,440 KB
testcase_21 AC 145 ms
15,276 KB
testcase_22 AC 125 ms
11,904 KB
testcase_23 AC 149 ms
14,912 KB
testcase_24 AC 128 ms
12,416 KB
testcase_25 AC 144 ms
13,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
import collections
C=collections.Counter(A)
a=len(C.keys())
n_max=10*3+1
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(range(n_max-1)):
  FI[i]=(FI[i+1]*(i+1))%mod
def comb(x,y):
  return (F[x]*FI[x-y]*FI[y])%mod
ans=0
import itertools
for c1,c2,c3 in itertools.combinations(C.keys(),3):
  ans=(ans+C[c1]*C[c2]*C[c3])%mod
print(ans)
0