結果

問題 No.1595 The Final Digit
ユーザー mrngmrng
提出日時 2021-12-13 21:15:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 284 bytes
コンパイル時間 695 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 71,596 KB
最終ジャッジ日時 2023-09-30 02:41:26
合計ジャッジ時間 2,849 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,332 KB
testcase_01 AC 70 ms
71,300 KB
testcase_02 AC 70 ms
71,452 KB
testcase_03 AC 71 ms
71,428 KB
testcase_04 AC 70 ms
71,380 KB
testcase_05 AC 70 ms
71,596 KB
testcase_06 AC 69 ms
71,204 KB
testcase_07 AC 69 ms
71,408 KB
testcase_08 AC 69 ms
71,368 KB
testcase_09 AC 70 ms
71,324 KB
testcase_10 AC 69 ms
71,064 KB
testcase_11 AC 69 ms
71,216 KB
testcase_12 AC 68 ms
71,296 KB
testcase_13 AC 69 ms
71,164 KB
testcase_14 AC 70 ms
71,316 KB
testcase_15 AC 70 ms
71,312 KB
testcase_16 AC 71 ms
71,496 KB
testcase_17 AC 72 ms
71,520 KB
testcase_18 AC 71 ms
71,064 KB
testcase_19 AC 70 ms
71,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p,q,r,k = map(int,input().split())
dp = [0]*1005
dp[1] = p%10
dp[2] = q%10
dp[3] = r%10
s = dp[1]*100+dp[2]*10+dp[3]
c = 0
for i in range(4,1005):
	dp[i] = dp[i-1]+dp[i-2]+dp[i-3]
	dp[i] %= 10
	if dp[i-2]*100+dp[i-1]*10+dp[i]==s:
		c = i-3
		break
print(dp[k%c] if k%c!=0 else dp[c])
0