結果

問題 No.747 循環小数N桁目 Hard
ユーザー tentententen
提出日時 2023-07-07 11:56:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 2,191 bytes
コンパイル時間 4,063 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 52,988 KB
最終ジャッジ日時 2023-09-28 12:21:43
合計ジャッジ時間 17,659 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,480 KB
testcase_01 AC 43 ms
49,556 KB
testcase_02 AC 42 ms
49,484 KB
testcase_03 AC 42 ms
49,524 KB
testcase_04 AC 43 ms
49,356 KB
testcase_05 AC 43 ms
49,372 KB
testcase_06 AC 44 ms
49,676 KB
testcase_07 AC 43 ms
49,520 KB
testcase_08 AC 43 ms
49,416 KB
testcase_09 AC 44 ms
49,372 KB
testcase_10 AC 42 ms
49,268 KB
testcase_11 AC 43 ms
49,324 KB
testcase_12 AC 46 ms
49,316 KB
testcase_13 AC 43 ms
49,400 KB
testcase_14 AC 44 ms
49,484 KB
testcase_15 AC 43 ms
49,332 KB
testcase_16 AC 43 ms
49,376 KB
testcase_17 AC 43 ms
49,548 KB
testcase_18 AC 43 ms
49,372 KB
testcase_19 AC 43 ms
49,604 KB
testcase_20 AC 42 ms
49,396 KB
testcase_21 AC 43 ms
49,784 KB
testcase_22 AC 43 ms
49,336 KB
testcase_23 AC 43 ms
49,548 KB
testcase_24 AC 43 ms
49,688 KB
testcase_25 AC 43 ms
47,348 KB
testcase_26 AC 43 ms
49,368 KB
testcase_27 AC 45 ms
49,336 KB
testcase_28 AC 42 ms
49,256 KB
testcase_29 AC 42 ms
49,500 KB
testcase_30 AC 42 ms
49,236 KB
testcase_31 AC 42 ms
49,480 KB
testcase_32 AC 44 ms
49,496 KB
testcase_33 AC 83 ms
51,888 KB
testcase_34 AC 56 ms
50,836 KB
testcase_35 AC 56 ms
50,412 KB
testcase_36 AC 59 ms
50,384 KB
testcase_37 AC 52 ms
50,472 KB
testcase_38 AC 62 ms
50,904 KB
testcase_39 AC 59 ms
50,608 KB
testcase_40 AC 89 ms
51,544 KB
testcase_41 AC 82 ms
52,300 KB
testcase_42 AC 82 ms
52,112 KB
testcase_43 AC 59 ms
50,404 KB
testcase_44 AC 79 ms
51,648 KB
testcase_45 AC 83 ms
51,984 KB
testcase_46 AC 81 ms
52,132 KB
testcase_47 AC 82 ms
51,704 KB
testcase_48 AC 59 ms
50,552 KB
testcase_49 AC 70 ms
51,408 KB
testcase_50 AC 59 ms
50,528 KB
testcase_51 AC 58 ms
50,692 KB
testcase_52 AC 55 ms
50,360 KB
testcase_53 AC 123 ms
50,528 KB
testcase_54 AC 98 ms
52,452 KB
testcase_55 AC 116 ms
52,220 KB
testcase_56 AC 99 ms
51,968 KB
testcase_57 AC 59 ms
50,596 KB
testcase_58 AC 124 ms
52,404 KB
testcase_59 AC 72 ms
51,176 KB
testcase_60 AC 101 ms
50,348 KB
testcase_61 AC 94 ms
51,844 KB
testcase_62 AC 94 ms
51,812 KB
testcase_63 AC 82 ms
52,264 KB
testcase_64 AC 58 ms
50,384 KB
testcase_65 AC 49 ms
49,800 KB
testcase_66 AC 63 ms
50,652 KB
testcase_67 AC 58 ms
50,528 KB
testcase_68 AC 86 ms
51,968 KB
testcase_69 AC 81 ms
51,888 KB
testcase_70 AC 58 ms
50,716 KB
testcase_71 AC 57 ms
50,588 KB
testcase_72 AC 62 ms
50,552 KB
testcase_73 AC 86 ms
52,472 KB
testcase_74 AC 82 ms
52,356 KB
testcase_75 AC 59 ms
50,648 KB
testcase_76 AC 64 ms
50,564 KB
testcase_77 AC 61 ms
50,420 KB
testcase_78 AC 82 ms
51,976 KB
testcase_79 AC 81 ms
51,424 KB
testcase_80 AC 81 ms
52,040 KB
testcase_81 AC 58 ms
48,700 KB
testcase_82 AC 60 ms
50,364 KB
testcase_83 AC 59 ms
50,584 KB
testcase_84 AC 81 ms
51,004 KB
testcase_85 AC 82 ms
52,232 KB
testcase_86 AC 75 ms
51,424 KB
testcase_87 AC 86 ms
52,240 KB
testcase_88 AC 63 ms
50,820 KB
testcase_89 AC 62 ms
50,652 KB
testcase_90 AC 81 ms
52,112 KB
testcase_91 AC 85 ms
51,984 KB
testcase_92 AC 79 ms
51,184 KB
testcase_93 AC 82 ms
52,480 KB
testcase_94 AC 94 ms
52,680 KB
testcase_95 AC 116 ms
52,268 KB
testcase_96 AC 114 ms
51,948 KB
testcase_97 AC 104 ms
52,336 KB
testcase_98 AC 123 ms
52,976 KB
testcase_99 AC 111 ms
52,460 KB
testcase_100 AC 112 ms
52,464 KB
testcase_101 AC 82 ms
52,324 KB
testcase_102 AC 78 ms
52,044 KB
testcase_103 AC 84 ms
52,300 KB
testcase_104 AC 84 ms
52,484 KB
testcase_105 AC 87 ms
52,436 KB
testcase_106 AC 81 ms
52,504 KB
testcase_107 AC 85 ms
52,124 KB
testcase_108 AC 82 ms
52,480 KB
testcase_109 AC 88 ms
52,204 KB
testcase_110 AC 80 ms
52,100 KB
testcase_111 AC 83 ms
52,528 KB
testcase_112 AC 81 ms
52,248 KB
testcase_113 AC 85 ms
52,988 KB
testcase_114 AC 83 ms
52,564 KB
testcase_115 AC 83 ms
52,460 KB
testcase_116 AC 83 ms
52,408 KB
testcase_117 AC 83 ms
52,940 KB
testcase_118 AC 81 ms
52,544 KB
testcase_119 AC 81 ms
52,048 KB
testcase_120 AC 81 ms
52,520 KB
testcase_121 AC 82 ms
52,544 KB
testcase_122 AC 81 ms
52,500 KB
testcase_123 AC 80 ms
52,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    static final int MOD = 6;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        char[] base = "285714".toCharArray();
        int n = 0;
        for (char c : sc.next().toCharArray()) {
            n *= 10;
            n += c - '0';
            n %= MOD;
        }
        int ans = 1;
        char[] p = sc.next().toCharArray();
        for (int i = p.length - 1; i >= 0; i--) {
            int x = p[i] - '0';
            ans *= pow(n, x);
            ans %= MOD;
            n = pow(n, 10);
        }
        ans += 5;
        ans %= MOD;
        System.out.println(base[ans]);
    }
    
    static int pow(int x, int p) {
        if (p == 0) {
            return 1;
        } else if (p % 2 == 0) {
            return pow(x * x % MOD, p / 2);
        } else {
            return pow(x, p - 1) * x % MOD;
        }
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0