結果

問題 No.352 カード並べ
ユーザー yumechi
提出日時 2016-03-12 01:03:10
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-25 01:44:57
合計ジャッジ時間 957 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations

def solve():
    n = int(input())
    fact = [1]*21
    for i in range(1, 21):
        fact[i] *= (i+1) * fact[i-1]
    res = 1.0
    for i in range(2, n+1):
        tres = 2 * (1 / i)
        for elem in combinations([j for j in range(1, i)], 2):
            tres += elem[0] * elem[1] * 2 * (fact[i-3] / fact[i-2]) * (1 / i)
        res += tres
    print(res)

if __name__=="__main__":
    solve()
0