結果

問題 No.167 N^M mod 10
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-12 01:07:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,516 bytes
コンパイル時間 2,050 ms
コンパイル使用メモリ 73,784 KB
実行使用メモリ 56,684 KB
最終ジャッジ日時 2023-09-17 19:36:37
合計ジャッジ時間 7,109 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
39,132 KB
testcase_01 AC 110 ms
40,004 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 151 ms
39,792 KB
testcase_05 WA -
testcase_06 AC 110 ms
39,072 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 109 ms
38,928 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 109 ms
39,344 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 109 ms
39,068 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 112 ms
39,200 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 130 ms
39,556 KB
testcase_27 WA -
testcase_28 AC 157 ms
39,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        String n = koko.next();
        String m = koko.next();
        char nn = n.charAt(n.length()-1);
        char[] mm = new char[2];
        if(m.length()==1&&m.charAt(m.length()-1)=='0'){
            System.out.println(1);
        }else{
            if(m.length()==1){
                mm[0] = 0;
                mm[1] = m.charAt(m.length()-1);
            }else{
                mm[0] = m.charAt(m.length()-2);
                mm[1] = m.charAt(m.length()-1);
                String mmm = String.valueOf(mm);
                int mnum = Integer.parseInt(mmm);
                int nnum = Character.getNumericValue(nn);
                if(nnum<2||nnum==5||nnum==6){
                    System.out.println(nnum);
                }else if(nnum==2){
                    System.out.println((6*(Math.pow(2,mnum%4)))%10);
                }else if(nnum==3){
                    System.out.println((Math.pow(3,mnum%4))%10);
                }else if(nnum==4){
                    System.out.println((6*(Math.pow(4,mnum%2)))%10);
                }else if(nnum==7){
                    System.out.println((Math.pow(7,mnum%4))%10);
                }else if(nnum==8){
                    System.out.println(6*(Math.pow(8,mnum%4))%10);
                }else{
                    System.out.println((Math.pow(9,mnum%2))%10);
                }
            }
        }
    }
}



0