結果
| 問題 | No.167 N^M mod 10 |
| コンテスト | |
| ユーザー |
hanorver
|
| 提出日時 | 2016-06-06 10:53:05 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 297 bytes |
| 記録 | |
| コンパイル時間 | 59 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 22,572 KB |
| 最終ジャッジ日時 | 2026-09-12 04:05:54 |
| 合計ジャッジ時間 | 5,102 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
hanorver