結果
問題 |
No.167 N^M mod 10
|
ユーザー |
![]() |
提出日時 | 2016-06-06 10:53:05 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 297 bytes |
コンパイル時間 | 375 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 22,684 KB |
最終ジャッジ日時 | 2024-10-08 16:24:53 |
合計ジャッジ時間 | 2,844 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 1 TLE * 1 -- * 25 |
ソースコード
def pow(n, m): if m == 1: return n if m % 2 == 1: return (pow(n, m - 1) * n) % 10 else: ret = pow(n, m // 2) return (ret ** 2) % 10 if __name__ == "__main__": n = int(input()) m = int(input()) ans = (n ** (m // 2) % 10) print(ans * ans % 10)