結果
| 問題 |
No.167 N^M mod 10
|
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2016-11-20 02:42:25 |
| 言語 | Java (openjdk 23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 534 bytes |
| コンパイル時間 | 3,021 ms |
| コンパイル使用メモリ | 73,668 KB |
| 実行使用メモリ | 41,684 KB |
| 最終ジャッジ日時 | 2024-11-27 06:36:03 |
| 合計ジャッジ時間 | 7,651 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 RE * 12 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long N = sc.nextLong();
long M = sc.nextLong();
long r = powmod(N,M);
System.out.println(r);
}
static long powmod(long a, long b){
a%=10;
long x=1;
if(b==0){
return 1;
}else if(b%2==0){
x = powmod(a*a%10, b/2)%10;
}else{
x = a*powmod(a*a%10, b/2)%10;
}
return x;
}
}
kohaku_kohaku