結果
問題 | No.118 門松列(2) |
ユーザー |
![]() |
提出日時 | 2020-05-22 00:18:40 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 165 ms / 5,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 16,736 KB |
最終ジャッジ日時 | 2024-10-02 10:51:06 |
合計ジャッジ時間 | 4,764 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
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)