結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 2015-12-30 00:32:39 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 51 ms / 1,000 ms |
コード長 | 637 bytes |
コンパイル時間 | 2,287 ms |
コンパイル使用メモリ | 74,584 KB |
実行使用メモリ | 37,044 KB |
最終ジャッジ日時 | 2024-09-22 01:24:27 |
合計ジャッジ時間 | 4,102 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
import java.io.*; import java.util.*; import java.math.*; class Main167 { public static void out (Object out) { System.out.println(out); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s1 = br.readLine(); String s2 = br.readLine(); int n = s1.charAt(s1.length() - 1) - '0'; int m = s2.length() >= 2 ? Integer.parseInt(s2.substring(s2.length() - 2 , s2.length())) : Integer.parseInt(s2); if (s2.equals("0")) { out(1); } else { m %= 4; if (m == 0) m = 4; out((int)Math.pow(n, m) % 10); } } }