結果

問題 No.1595 The Final Digit
ユーザー とりゐとりゐ
提出日時 2021-07-09 21:49:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,360 KB
実行使用メモリ 76,240 KB
最終ジャッジ日時 2023-09-14 08:29:04
合計ジャッジ時間 3,268 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,548 KB
testcase_01 AC 98 ms
76,240 KB
testcase_02 AC 92 ms
71,244 KB
testcase_03 AC 92 ms
71,692 KB
testcase_04 AC 92 ms
71,604 KB
testcase_05 AC 90 ms
71,384 KB
testcase_06 AC 90 ms
71,756 KB
testcase_07 AC 90 ms
71,244 KB
testcase_08 AC 89 ms
71,684 KB
testcase_09 AC 97 ms
76,232 KB
testcase_10 AC 99 ms
75,972 KB
testcase_11 AC 99 ms
76,044 KB
testcase_12 AC 95 ms
76,240 KB
testcase_13 AC 95 ms
76,144 KB
testcase_14 AC 97 ms
76,048 KB
testcase_15 AC 97 ms
76,000 KB
testcase_16 AC 95 ms
76,024 KB
testcase_17 AC 92 ms
71,392 KB
testcase_18 AC 96 ms
76,008 KB
testcase_19 AC 93 ms
71,440 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