結果
問題 | No.567 コンプリート |
ユーザー | H3PO4 |
提出日時 | 2020-10-03 08:54:24 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 133 ms / 2,000 ms |
コード長 | 472 bytes |
コンパイル時間 | 88 ms |
コンパイル使用メモリ | 11,012 KB |
実行使用メモリ | 31,664 KB |
最終ジャッジ日時 | 2023-09-25 04:51:20 |
合計ジャッジ時間 | 3,111 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 130 ms
29,820 KB |
testcase_01 | AC | 129 ms
29,960 KB |
testcase_02 | AC | 127 ms
29,896 KB |
testcase_03 | AC | 133 ms
29,908 KB |
testcase_04 | AC | 128 ms
29,836 KB |
testcase_05 | AC | 125 ms
29,852 KB |
testcase_06 | AC | 128 ms
29,868 KB |
testcase_07 | AC | 128 ms
29,808 KB |
testcase_08 | AC | 130 ms
29,840 KB |
testcase_09 | AC | 130 ms
31,664 KB |
testcase_10 | AC | 128 ms
29,864 KB |
testcase_11 | AC | 128 ms
31,428 KB |
testcase_12 | AC | 126 ms
30,044 KB |
testcase_13 | AC | 126 ms
29,828 KB |
testcase_14 | AC | 128 ms
29,932 KB |
testcase_15 | AC | 129 ms
29,776 KB |
ソースコード
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])