結果

問題 No.1595 The Final Digit
ユーザー とりゐとりゐ
提出日時 2021-07-09 21:46:40
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 729 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 79,624 KB
最終ジャッジ日時 2023-09-14 08:25:21
合計ジャッジ時間 3,536 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
71,712 KB
testcase_01 AC 107 ms
76,204 KB
testcase_02 RE -
testcase_03 AC 103 ms
71,352 KB
testcase_04 AC 99 ms
71,532 KB
testcase_05 AC 99 ms
71,088 KB
testcase_06 AC 102 ms
71,472 KB
testcase_07 AC 98 ms
71,292 KB
testcase_08 AC 98 ms
71,684 KB
testcase_09 AC 103 ms
75,932 KB
testcase_10 AC 102 ms
75,860 KB
testcase_11 AC 101 ms
75,976 KB
testcase_12 AC 102 ms
75,996 KB
testcase_13 AC 101 ms
75,864 KB
testcase_14 AC 105 ms
76,020 KB
testcase_15 AC 106 ms
75,976 KB
testcase_16 AC 108 ms
76,092 KB
testcase_17 AC 102 ms
71,520 KB
testcase_18 AC 107 ms
76,156 KB
testcase_19 AC 101 ms
71,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
from collections import deque,Counter
#sys.setrecursionlimit(10**7)
int1=lambda x: int(x)-1

mi=lambda :map(int,input().split())
li=lambda :list(mi())
mi1=lambda :map(int1,input().split())
li1=lambda :list(mi1())
mis=lambda :map(str,input().split())
lis=lambda :list(mis())

from collections import defaultdict
"""
d=defaultdict(int) #初期値 0
d=defaultdict(lambda:1) #初期値 1
"""

mod=10**9+7
Mod=998244353
INF=10**18
ans=0

p,q,r,k=mi()
p%=10
q%=10
r%=10
a=[(p,q,r)]
while True:
  p,q,r=q,r,(p+q+r)%10
  if (p,q,r) in a:
    x=a.index((p,q,r))
    y=len(a)
    if y>=k-3:
      print(a[k-3][2])
      exit()
    m=k-x-3
    n=m%(y-x)
    print(a[x+n][2])
    exit()
  else:
    a.append((p,q,r))  
0