結果
| 問題 | No.108 トリプルカードコンプ |
| コンテスト | |
| ユーザー |
🍡yurahuna
|
| 提出日時 | 2016-02-28 22:45:30 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 321 ms / 5,000 ms |
| コード長 | 702 bytes |
| コンパイル時間 | 327 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 25,088 KB |
| 最終ジャッジ日時 | 2024-09-24 12:21:13 |
| 合計ジャッジ時間 | 3,427 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
# -*- coding: utf-8 -*-
dp = [[[-1] * 101 for j in range(101)] for i in range(101)]
def solve(a, b, c):
s = a + b + c
if s == 0:
dp[a][b][c] = 0
if dp[a][b][c] >= 0:
return dp[a][b][c]
# a, b, cのいずれかが出る(自己ループを抜ける)までの回数の期待値
dp[a][b][c] = N / s
if a > 0:
dp[a][b][c] += solve(a-1, b+1, c) * a / s
if b > 0:
dp[a][b][c] += solve(a, b-1, c+1) * b / s
if c > 0:
dp[a][b][c] += solve(a, b, c-1) * c / s
return dp[a][b][c]
N = int(input())
A = list(map(int, input().split()))
num = [0, 0, 0]
for x in A:
if x < 3:
num[x] += 1
print(solve(num[0], num[1], num[2]))
🍡yurahuna