結果

問題 No.167 N^M mod 10
ユーザー HachimoriHachimori
提出日時 2015-03-20 00:05:13
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 474 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 6,636 KB
実行使用メモリ 6,232 KB
最終ジャッジ日時 2023-09-11 08:50:02
合計ジャッジ時間 2,185 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,064 KB
testcase_01 AC 12 ms
6,072 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 12 ms
6,112 KB
testcase_06 AC 11 ms
5,980 KB
testcase_07 AC 11 ms
6,016 KB
testcase_08 AC 11 ms
6,060 KB
testcase_09 AC 11 ms
5,980 KB
testcase_10 AC 11 ms
6,232 KB
testcase_11 AC 12 ms
6,004 KB
testcase_12 AC 12 ms
6,072 KB
testcase_13 AC 11 ms
6,232 KB
testcase_14 AC 11 ms
5,956 KB
testcase_15 AC 12 ms
6,072 KB
testcase_16 AC 11 ms
6,076 KB
testcase_17 AC 11 ms
6,108 KB
testcase_18 AC 12 ms
6,004 KB
testcase_19 AC 11 ms
6,124 KB
testcase_20 AC 11 ms
6,116 KB
testcase_21 AC 12 ms
6,160 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 12 ms
6,108 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

import sys
sys.setrecursionlimit(80000)

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)):
    if not (1 <= N <= 10**10000 and 0 <= M <= 10**1000):
        print "??"
        return
    
    N %= 10
    print mypow(N, M)
    

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