結果
問題 |
No.567 コンプリート
|
ユーザー |
|
提出日時 | 2020-10-03 08:54:24 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 510 ms / 2,000 ms |
コード長 | 472 bytes |
コンパイル時間 | 131 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 46,456 KB |
最終ジャッジ日時 | 2024-07-18 04:08:32 |
合計ジャッジ時間 | 8,916 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 |
ソースコード
import numpy as np def pow_matrix_mod(x, n): if not n: return np.eye(len(x), dtype=float) if n % 2 == 0: return pow_matrix_mod(x @ x, n // 2) else: return x @ pow_matrix_mod(x @ x, (n - 1) // 2) N = int(input()) dp = np.zeros(7, dtype=float) dp[0] = 1.0 A = [[0] * 7 for _ in range(7)] for i in range(6): A[i][i + 1] = (6 - i) / 6 A[i + 1][i + 1] = (i + 1) / 6 A = np.array(A) res = dp @ pow_matrix_mod(A, N) print(res[6])