結果

問題 No.167 N^M mod 10
ユーザー flippergoflippergo
提出日時 2021-01-01 17:08:41
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 296 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 65,280 KB
最終ジャッジ日時 2024-04-19 19:54:56
合計ジャッジ時間 3,105 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
51,456 KB
testcase_01 AC 46 ms
51,456 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 46 ms
51,968 KB
testcase_06 AC 46 ms
51,712 KB
testcase_07 AC 47 ms
51,712 KB
testcase_08 AC 48 ms
51,712 KB
testcase_09 AC 49 ms
51,200 KB
testcase_10 AC 46 ms
52,096 KB
testcase_11 AC 48 ms
51,456 KB
testcase_12 AC 47 ms
51,200 KB
testcase_13 AC 47 ms
51,456 KB
testcase_14 AC 47 ms
51,968 KB
testcase_15 AC 41 ms
51,584 KB
testcase_16 AC 43 ms
51,712 KB
testcase_17 AC 47 ms
51,584 KB
testcase_18 AC 44 ms
51,456 KB
testcase_19 AC 41 ms
51,456 KB
testcase_20 AC 43 ms
51,200 KB
testcase_21 AC 42 ms
51,200 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 45 ms
51,584 KB
testcase_27 RE -
testcase_28 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input().strip()
M = input().strip()
n = int(N[-1])
k = 1
x = (n**2)%10
k = 2
while x!=n:
    k += 1
    x = (x*n)%10
T = k-1
if M=="0" or N=="1":
    print(1)
else:
    m = int(M)%T
    if m==0:
        m = T
    k = 1
    x = n
    while k<m:
        x = (x*n)%10
        k += 1
    print(x)
0