結果

問題 No.167 N^M mod 10
ユーザー HachimoriHachimori
提出日時 2015-03-20 00:19:31
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 698 ms
コンパイル使用メモリ 6,532 KB
実行使用メモリ 6,308 KB
最終ジャッジ日時 2023-09-11 08:54:43
合計ジャッジ時間 1,656 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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


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


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

    cur = 1
    visited = [-1 for i in range(10)]
    
    for loop in range(100):
        if visited[cur] != -1:
            cycle = loop - visited[cur] + 1
            break
        
        visited[cur] = loop
        cur = cur * N % 10

    cur = 1
    for i in range(M % cycle):
        cur = cur * N % 10
    print cur
    

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