結果
問題 | No.1595 The Final Digit |
ユーザー | norioc |
提出日時 | 2021-07-10 02:17:12 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 553 bytes |
コンパイル時間 | 91 ms |
コンパイル使用メモリ | 10,876 KB |
実行使用メモリ | 8,640 KB |
最終ジャッジ日時 | 2023-09-14 13:53:48 |
合計ジャッジ時間 | 1,522 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 18 ms
8,472 KB |
testcase_03 | WA | - |
testcase_04 | AC | 19 ms
8,628 KB |
testcase_05 | AC | 19 ms
8,468 KB |
testcase_06 | AC | 18 ms
8,468 KB |
testcase_07 | AC | 18 ms
8,468 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 18 ms
8,592 KB |
testcase_13 | AC | 18 ms
8,452 KB |
testcase_14 | AC | 18 ms
8,476 KB |
testcase_15 | AC | 18 ms
8,480 KB |
testcase_16 | AC | 18 ms
8,464 KB |
testcase_17 | WA | - |
testcase_18 | AC | 19 ms
8,476 KB |
testcase_19 | AC | 18 ms
8,468 KB |
ソースコード
import collections from itertools import count p, q, r, K = map(int, input().split()) p %= 10 q %= 10 r %= 10 memo = collections.defaultdict(int) memo[p, q, r] = 2 a = [p, q, r] for i in count(3): x = (a[-1] + a[-2] + a[-3]) % 10 a.append(x) if i == K: print(a[-1]) break key = (a[-3], a[-2], a[-1]) if key in memo: # found cycle loop_start = memo[key] loop_len = i - loop_start index = ((K - 1) - loop_start) % loop_len + loop_start print(a[index]) break memo[key] = i