結果

問題 No.813 ユキちゃんの冒険
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-08 21:30:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 727 ms / 2,000 ms
コード長 493 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,084 KB
実行使用メモリ 109,388 KB
最終ジャッジ日時 2023-10-21 07:27:54
合計ジャッジ時間 15,629 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 479 ms
42,340 KB
testcase_01 AC 486 ms
44,184 KB
testcase_02 AC 499 ms
52,220 KB
testcase_03 AC 495 ms
48,592 KB
testcase_04 AC 727 ms
109,388 KB
testcase_05 AC 684 ms
102,020 KB
testcase_06 AC 507 ms
58,212 KB
testcase_07 AC 482 ms
44,184 KB
testcase_08 AC 570 ms
76,120 KB
testcase_09 AC 489 ms
44,184 KB
testcase_10 AC 489 ms
54,952 KB
testcase_11 AC 483 ms
47,536 KB
testcase_12 AC 566 ms
76,788 KB
testcase_13 AC 507 ms
59,452 KB
testcase_14 AC 485 ms
42,340 KB
testcase_15 AC 630 ms
92,692 KB
testcase_16 AC 652 ms
96,096 KB
testcase_17 AC 479 ms
45,424 KB
testcase_18 AC 478 ms
44,184 KB
testcase_19 AC 700 ms
108,452 KB
testcase_20 AC 491 ms
48,856 KB
testcase_21 AC 488 ms
45,424 KB
testcase_22 AC 487 ms
45,424 KB
testcase_23 AC 529 ms
61,928 KB
testcase_24 AC 486 ms
42,340 KB
testcase_25 AC 720 ms
109,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
eps = 1e-6

n = int(input())
p = float(input())
q = float(input())
if abs(p - 1) < eps:
    print(1.0)
    exit()

A = np.eye(n * 2, dtype=np.float64)
X = np.arange(1, n * 2)
Y = np.arange(1, n * 2)
Y[X % 2 == 0] += 1
Y[X % 2 == 1] -= 1
np.add.at(A, (X, Y), -p)

X = np.arange(1, n * 2 - 1)
Z = np.arange(1, n * 2 - 1)
Z[X % 2 == 0] -= 2
Z[X % 2 == 1] += 2
np.add.at(A, (X, Z), -q)

b = np.zeros(2 * n, dtype=np.float64)
b[0] = 1.0

res = np.linalg.solve(A, b)
print(res[1])
0