結果
問題 | No.1501 酔歩 |
ユーザー | kimiyuki |
提出日時 | 2021-05-07 22:20:14 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,080 bytes |
コンパイル時間 | 326 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 32,560 KB |
最終ジャッジ日時 | 2024-09-15 10:24:29 |
合計ジャッジ時間 | 54,104 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
12,160 KB |
testcase_01 | AC | 44 ms
12,032 KB |
testcase_02 | AC | 43 ms
12,032 KB |
testcase_03 | AC | 44 ms
12,160 KB |
testcase_04 | RE | - |
testcase_05 | AC | 1,276 ms
27,932 KB |
testcase_06 | AC | 954 ms
23,984 KB |
testcase_07 | AC | 1,226 ms
26,984 KB |
testcase_08 | AC | 285 ms
15,616 KB |
testcase_09 | AC | 1,099 ms
25,476 KB |
testcase_10 | AC | 412 ms
17,152 KB |
testcase_11 | AC | 986 ms
23,716 KB |
testcase_12 | AC | 631 ms
20,308 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | AC | 1,552 ms
32,296 KB |
testcase_23 | AC | 1,624 ms
32,548 KB |
testcase_24 | AC | 1,586 ms
32,428 KB |
testcase_25 | AC | 1,537 ms
32,556 KB |
testcase_26 | AC | 1,493 ms
32,560 KB |
testcase_27 | AC | 1,568 ms
32,292 KB |
testcase_28 | AC | 1,670 ms
32,292 KB |
testcase_29 | AC | 1,471 ms
32,420 KB |
testcase_30 | AC | 1,717 ms
32,524 KB |
testcase_31 | AC | 1,473 ms
32,548 KB |
testcase_32 | AC | 1,495 ms
32,300 KB |
testcase_33 | AC | 1,625 ms
32,424 KB |
testcase_34 | AC | 1,606 ms
32,304 KB |
testcase_35 | AC | 1,549 ms
32,428 KB |
testcase_36 | AC | 1,592 ms
32,432 KB |
testcase_37 | AC | 1,462 ms
32,420 KB |
testcase_38 | AC | 1,493 ms
32,300 KB |
testcase_39 | AC | 1,706 ms
32,180 KB |
testcase_40 | AC | 1,522 ms
32,428 KB |
testcase_41 | AC | 1,616 ms
32,424 KB |
testcase_42 | AC | 1,336 ms
30,004 KB |
testcase_43 | RE | - |
testcase_44 | RE | - |
testcase_45 | AC | 1,411 ms
29,868 KB |
testcase_46 | AC | 1,492 ms
29,864 KB |
testcase_47 | AC | 1,311 ms
29,868 KB |
testcase_48 | AC | 1,363 ms
29,976 KB |
testcase_49 | AC | 1,488 ms
29,972 KB |
testcase_50 | AC | 1,368 ms
30,100 KB |
testcase_51 | AC | 1,356 ms
30,104 KB |
testcase_52 | AC | 1,344 ms
30,096 KB |
testcase_53 | RE | - |
testcase_54 | AC | 42 ms
12,160 KB |
testcase_55 | AC | 43 ms
12,160 KB |
ソースコード
#!/usr/bin/env python3 import fractions from typing import * def solve(n: int, k: int, x: List[int]) -> str: a = [None] * (n - 1) b = [None] * (n - 1) a[0] = 0 b[0] = 0 for i in range(1, n - 1): left = fractions.Fraction(x[i - 1], x[i - 1] + x[i + 1]) right = fractions.Fraction(x[i + 1], x[i - 1] + x[i + 1]) a[i] = right / (1 - a[i - 1] * left) b[i] = b[i - 1] * left / (1 - a[i - 1] * left) if k == n: return 1 c = 1 for i in reversed(range(k - 1, n - 1)): c = a[i] * c + b[i] return c # generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator) def main(): import sys tokens = iter(sys.stdin.read().split()) N = int(next(tokens)) K = int(next(tokens)) A = [None for _ in range(N)] for i in range(N): A[i] = int(next(tokens)) assert next(tokens, None) is None a = solve(N, K, A) if a == 0: print(0) elif a == 1: print('1/1') else: print(a) if __name__ == '__main__': main()