結果

問題 No.167 N^M mod 10
ユーザー HachimoriHachimori
提出日時 2015-03-19 23:49:27
言語 Python2
(2.7.18)
結果
RE  
実行時間 -
コード長 377 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 6,648 KB
実行使用メモリ 30,184 KB
最終ジャッジ日時 2023-09-11 08:45:20
合計ジャッジ時間 2,823 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,052 KB
testcase_01 AC 11 ms
5,980 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 11 ms
6,168 KB
testcase_06 AC 11 ms
5,996 KB
testcase_07 AC 12 ms
6,052 KB
testcase_08 AC 11 ms
6,136 KB
testcase_09 AC 12 ms
5,960 KB
testcase_10 AC 11 ms
5,984 KB
testcase_11 AC 12 ms
6,056 KB
testcase_12 AC 11 ms
5,988 KB
testcase_13 AC 11 ms
6,168 KB
testcase_14 AC 11 ms
6,072 KB
testcase_15 AC 11 ms
5,984 KB
testcase_16 AC 11 ms
6,048 KB
testcase_17 AC 11 ms
5,976 KB
testcase_18 AC 11 ms
6,088 KB
testcase_19 AC 12 ms
6,236 KB
testcase_20 AC 11 ms
6,004 KB
testcase_21 AC 12 ms
6,076 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 12 ms
6,108 KB
testcase_27 RE -
testcase_28 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

import sys
sys.setrecursionlimit(5000)

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


def mypow(n, p):
    if p == 0:
        return 1

    t = mypow(n, p / 2)

    return t * t * n % 10 if p % 2 == 1 else t * t % 10
    

def work((N, M)):
    N %= 10
    print mypow(N, M)
    

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