結果

問題 No.167 N^M mod 10
ユーザー FromBooskaFromBooska
提出日時 2023-08-03 11:45:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 51 ms / 1,000 ms
コード長 407 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 53,348 KB
最終ジャッジ日時 2024-04-21 09:36:53
合計ジャッジ時間 2,939 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
52,532 KB
testcase_01 AC 47 ms
51,832 KB
testcase_02 AC 47 ms
51,492 KB
testcase_03 AC 48 ms
52,640 KB
testcase_04 AC 48 ms
52,312 KB
testcase_05 AC 47 ms
52,756 KB
testcase_06 AC 46 ms
52,696 KB
testcase_07 AC 47 ms
53,184 KB
testcase_08 AC 48 ms
52,512 KB
testcase_09 AC 51 ms
52,376 KB
testcase_10 AC 47 ms
52,676 KB
testcase_11 AC 47 ms
53,132 KB
testcase_12 AC 48 ms
51,624 KB
testcase_13 AC 48 ms
53,348 KB
testcase_14 AC 48 ms
52,336 KB
testcase_15 AC 47 ms
52,988 KB
testcase_16 AC 47 ms
52,424 KB
testcase_17 AC 47 ms
51,868 KB
testcase_18 AC 46 ms
52,632 KB
testcase_19 AC 47 ms
52,468 KB
testcase_20 AC 49 ms
51,892 KB
testcase_21 AC 48 ms
53,044 KB
testcase_22 AC 46 ms
52,488 KB
testcase_23 AC 49 ms
52,504 KB
testcase_24 AC 48 ms
51,880 KB
testcase_25 AC 48 ms
52,336 KB
testcase_26 AC 47 ms
52,360 KB
testcase_27 AC 48 ms
53,076 KB
testcase_28 AC 48 ms
52,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# Nは下1桁だけが重要
# Mはmod 4だけみればいい
# M=0なら1
# リジャッジでRE出た、アルゴリズムはいいと思う
# N, Mが超巨大数の可能性があるので文字列で受け取るか

N = input()
N_lastdigit = int(N[-1])
M = input()
if M == '0':
    print(1)
else:
    M = int(M[-3:])
    M_mod4 = M%4
    ans = pow(N_lastdigit, M_mod4+4, 10)
    print(ans)
    #print(M)
0