結果

問題 No.167 N^M mod 10
ユーザー しらっ亭しらっ亭
提出日時 2016-02-12 01:48:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 222 ms / 1,000 ms
コード長 290 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 11,656 KB
実行使用メモリ 10,364 KB
最終ジャッジ日時 2023-10-22 00:01:56
合計ジャッジ時間 3,431 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,332 KB
testcase_01 AC 31 ms
10,336 KB
testcase_02 AC 177 ms
10,364 KB
testcase_03 AC 178 ms
10,364 KB
testcase_04 AC 177 ms
10,364 KB
testcase_05 AC 31 ms
10,332 KB
testcase_06 AC 32 ms
10,332 KB
testcase_07 AC 31 ms
10,332 KB
testcase_08 AC 33 ms
10,332 KB
testcase_09 AC 32 ms
10,332 KB
testcase_10 AC 32 ms
10,332 KB
testcase_11 AC 32 ms
10,332 KB
testcase_12 AC 32 ms
10,332 KB
testcase_13 AC 31 ms
10,332 KB
testcase_14 AC 31 ms
10,332 KB
testcase_15 AC 31 ms
10,332 KB
testcase_16 AC 31 ms
10,332 KB
testcase_17 AC 31 ms
10,332 KB
testcase_18 AC 32 ms
10,336 KB
testcase_19 AC 32 ms
10,336 KB
testcase_20 AC 33 ms
10,332 KB
testcase_21 AC 33 ms
10,336 KB
testcase_22 AC 175 ms
10,364 KB
testcase_23 AC 174 ms
10,364 KB
testcase_24 AC 222 ms
10,364 KB
testcase_25 AC 175 ms
10,364 KB
testcase_26 AC 31 ms
10,352 KB
testcase_27 AC 169 ms
10,364 KB
testcase_28 AC 32 ms
10,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from decimal import Decimal, getcontext


def solve():
    N = input()
    M = input()

    n = Decimal(N[-1])
    m = Decimal(M)

    if m == 0:
        print(1)
        return

    ctx = getcontext()

    ans = ctx.power(n, m, 10)

    print(ans)


if __name__ == '__main__':
    solve()
0