結果

問題 No.167 N^M mod 10
ユーザー Hachimori
提出日時 2015-03-20 00:32:37
言語 Python2
(2.7.18)
結果
AC  
実行時間 598 ms / 1,000 ms
コード長 319 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-09-22 01:09:07
合計ジャッジ時間 6,500 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python
#coding:utf8


def read():
    N = input()
    M = input()
    return N, M


def work((N, M)):
    N %= 10
    
    ans = 1
    while M:
        if M % 2 == 1:
           ans = ans * N % 10
        N = N * N % 10
        M /= 2
    
    print ans
    

if __name__ == "__main__":
    work(read())
0