結果

問題 No.167 N^M mod 10
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-20 02:42:25
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 534 bytes
コンパイル時間 3,416 ms
コンパイル使用メモリ 71,572 KB
実行使用メモリ 58,464 KB
最終ジャッジ日時 2023-08-18 04:01:27
合計ジャッジ時間 8,247 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
56,228 KB
testcase_01 AC 117 ms
56,124 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 117 ms
56,556 KB
testcase_06 AC 116 ms
56,168 KB
testcase_07 AC 117 ms
56,028 KB
testcase_08 AC 117 ms
56,084 KB
testcase_09 AC 119 ms
56,376 KB
testcase_10 AC 117 ms
56,552 KB
testcase_11 AC 119 ms
55,792 KB
testcase_12 AC 118 ms
55,808 KB
testcase_13 AC 117 ms
56,344 KB
testcase_14 AC 118 ms
54,208 KB
testcase_15 AC 116 ms
56,136 KB
testcase_16 AC 117 ms
56,216 KB
testcase_17 AC 119 ms
56,136 KB
testcase_18 AC 116 ms
56,680 KB
testcase_19 AC 117 ms
56,084 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
    }
}
0