結果

問題 No.167 N^M mod 10
ユーザー steek79
提出日時 2015-10-21 20:43:24
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 424 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 6,784 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-09-22 01:22:40
合計ジャッジ時間 1,263 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
M = input()

N = N%10

if M == 0:
    print 1
    exit()

if N == 1:
    ans = 1
elif N == 2:
    ans = [2, 4, 8, 6][M%4-1]
elif N == 3:
    ans = [3, 9, 7, 1][M%4-1]
elif N == 4:
    ans = [4, 6][M%2-1]
elif N == 5:
    ans = 5
elif N == 6:
    ans = 6
elif N == 7:
    ans = [7, 9, 3, 1][M%4-1]
elif N == 8:
    ans = [8, 4, 2, 6][M%4-1]
elif N == 9:
    ans = [9, 1][M%2-1]
elif N == 0:
    ans = 0

print ans
0