結果

問題 No.167 N^M mod 10
コンテスト
ユーザー あかりき
提出日時 2021-03-01 18:48:28
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 31 ms / 1,000 ms
+ 956µs
コード長 300 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 71 ms
コンパイル使用メモリ 80,640 KB
実行使用メモリ 62,592 KB
最終ジャッジ日時 2026-09-09 07:56:49
合計ジャッジ時間 2,730 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n=list(input())
m=list(input())

if len(m)==1 and m[0]=='0':
  print(1)
  exit()

n=int(n[-1])
l=[n]
for i in range(100):
  if l[-1]*n%10!=l[0]:
    l.append(l[-1]*n%10)
  else:
    break

ct=0
m.reverse()
for i in range(len(m)):
  ct+=int(m[i])*pow(10,i,len(l))
  ct%=len(l)

print(l[(ct-1)%len(l)])
0