結果
問題 |
No.167 N^M mod 10
|
ユーザー |
![]() |
提出日時 | 2023-08-03 11:45:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 42 ms / 1,000 ms |
コード長 | 407 bytes |
コンパイル時間 | 182 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 52,096 KB |
最終ジャッジ日時 | 2024-10-13 08:29:50 |
合計ジャッジ時間 | 2,330 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
# 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)