結果
問題 | No.747 循環小数N桁目 Hard |
ユーザー | tenten |
提出日時 | 2023-07-07 11:56:56 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 141 ms / 2,000 ms |
コード長 | 2,191 bytes |
コンパイル時間 | 3,059 ms |
コンパイル使用メモリ | 91,388 KB |
実行使用メモリ | 39,668 KB |
最終ジャッジ日時 | 2024-07-21 06:59:35 |
合計ジャッジ時間 | 17,737 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
36,648 KB |
testcase_01 | AC | 58 ms
36,536 KB |
testcase_02 | AC | 59 ms
36,632 KB |
testcase_03 | AC | 58 ms
36,300 KB |
testcase_04 | AC | 59 ms
36,184 KB |
testcase_05 | AC | 58 ms
36,856 KB |
testcase_06 | AC | 58 ms
36,936 KB |
testcase_07 | AC | 58 ms
36,736 KB |
testcase_08 | AC | 59 ms
36,516 KB |
testcase_09 | AC | 59 ms
36,940 KB |
testcase_10 | AC | 58 ms
36,844 KB |
testcase_11 | AC | 60 ms
36,612 KB |
testcase_12 | AC | 58 ms
36,920 KB |
testcase_13 | AC | 57 ms
36,852 KB |
testcase_14 | AC | 58 ms
36,848 KB |
testcase_15 | AC | 59 ms
36,736 KB |
testcase_16 | AC | 57 ms
36,604 KB |
testcase_17 | AC | 60 ms
36,900 KB |
testcase_18 | AC | 56 ms
36,860 KB |
testcase_19 | AC | 57 ms
36,556 KB |
testcase_20 | AC | 57 ms
36,844 KB |
testcase_21 | AC | 59 ms
36,672 KB |
testcase_22 | AC | 56 ms
36,600 KB |
testcase_23 | AC | 58 ms
36,300 KB |
testcase_24 | AC | 59 ms
36,572 KB |
testcase_25 | AC | 58 ms
36,924 KB |
testcase_26 | AC | 57 ms
36,784 KB |
testcase_27 | AC | 59 ms
36,636 KB |
testcase_28 | AC | 61 ms
36,588 KB |
testcase_29 | AC | 57 ms
36,928 KB |
testcase_30 | AC | 59 ms
36,852 KB |
testcase_31 | AC | 58 ms
36,476 KB |
testcase_32 | AC | 58 ms
37,068 KB |
testcase_33 | AC | 103 ms
38,724 KB |
testcase_34 | AC | 79 ms
37,340 KB |
testcase_35 | AC | 77 ms
37,152 KB |
testcase_36 | AC | 81 ms
37,632 KB |
testcase_37 | AC | 65 ms
36,960 KB |
testcase_38 | AC | 76 ms
37,632 KB |
testcase_39 | AC | 74 ms
37,860 KB |
testcase_40 | AC | 100 ms
38,572 KB |
testcase_41 | AC | 101 ms
38,984 KB |
testcase_42 | AC | 108 ms
38,604 KB |
testcase_43 | AC | 78 ms
37,176 KB |
testcase_44 | AC | 105 ms
38,580 KB |
testcase_45 | AC | 102 ms
38,860 KB |
testcase_46 | AC | 109 ms
38,892 KB |
testcase_47 | AC | 100 ms
38,928 KB |
testcase_48 | AC | 75 ms
37,696 KB |
testcase_49 | AC | 76 ms
37,760 KB |
testcase_50 | AC | 75 ms
37,460 KB |
testcase_51 | AC | 75 ms
37,996 KB |
testcase_52 | AC | 77 ms
37,600 KB |
testcase_53 | AC | 141 ms
39,052 KB |
testcase_54 | AC | 116 ms
38,724 KB |
testcase_55 | AC | 126 ms
39,668 KB |
testcase_56 | AC | 122 ms
38,892 KB |
testcase_57 | AC | 74 ms
37,524 KB |
testcase_58 | AC | 135 ms
39,536 KB |
testcase_59 | AC | 86 ms
37,704 KB |
testcase_60 | AC | 120 ms
38,884 KB |
testcase_61 | AC | 103 ms
38,604 KB |
testcase_62 | AC | 101 ms
38,888 KB |
testcase_63 | AC | 100 ms
39,100 KB |
testcase_64 | AC | 75 ms
37,636 KB |
testcase_65 | AC | 64 ms
36,676 KB |
testcase_66 | AC | 77 ms
37,852 KB |
testcase_67 | AC | 75 ms
37,496 KB |
testcase_68 | AC | 99 ms
38,652 KB |
testcase_69 | AC | 107 ms
38,680 KB |
testcase_70 | AC | 75 ms
37,488 KB |
testcase_71 | AC | 81 ms
37,644 KB |
testcase_72 | AC | 76 ms
37,676 KB |
testcase_73 | AC | 101 ms
38,856 KB |
testcase_74 | AC | 87 ms
38,496 KB |
testcase_75 | AC | 80 ms
37,564 KB |
testcase_76 | AC | 77 ms
37,960 KB |
testcase_77 | AC | 79 ms
37,900 KB |
testcase_78 | AC | 98 ms
38,424 KB |
testcase_79 | AC | 76 ms
38,396 KB |
testcase_80 | AC | 99 ms
38,652 KB |
testcase_81 | AC | 72 ms
37,456 KB |
testcase_82 | AC | 76 ms
37,632 KB |
testcase_83 | AC | 77 ms
37,536 KB |
testcase_84 | AC | 102 ms
38,856 KB |
testcase_85 | AC | 100 ms
38,944 KB |
testcase_86 | AC | 99 ms
38,272 KB |
testcase_87 | AC | 109 ms
39,060 KB |
testcase_88 | AC | 79 ms
37,668 KB |
testcase_89 | AC | 78 ms
37,684 KB |
testcase_90 | AC | 87 ms
38,692 KB |
testcase_91 | AC | 98 ms
38,436 KB |
testcase_92 | AC | 79 ms
37,836 KB |
testcase_93 | AC | 102 ms
38,628 KB |
testcase_94 | AC | 105 ms
39,244 KB |
testcase_95 | AC | 140 ms
39,268 KB |
testcase_96 | AC | 112 ms
39,244 KB |
testcase_97 | AC | 121 ms
38,884 KB |
testcase_98 | AC | 136 ms
39,460 KB |
testcase_99 | AC | 123 ms
38,880 KB |
testcase_100 | AC | 130 ms
39,312 KB |
testcase_101 | AC | 90 ms
38,016 KB |
testcase_102 | AC | 101 ms
38,772 KB |
testcase_103 | AC | 101 ms
38,468 KB |
testcase_104 | AC | 103 ms
39,092 KB |
testcase_105 | AC | 104 ms
39,016 KB |
testcase_106 | AC | 100 ms
38,948 KB |
testcase_107 | AC | 99 ms
38,600 KB |
testcase_108 | AC | 100 ms
39,052 KB |
testcase_109 | AC | 104 ms
38,796 KB |
testcase_110 | AC | 101 ms
39,116 KB |
testcase_111 | AC | 101 ms
38,756 KB |
testcase_112 | AC | 100 ms
38,948 KB |
testcase_113 | AC | 102 ms
39,036 KB |
testcase_114 | AC | 104 ms
39,092 KB |
testcase_115 | AC | 100 ms
38,808 KB |
testcase_116 | AC | 103 ms
38,756 KB |
testcase_117 | AC | 108 ms
38,748 KB |
testcase_118 | AC | 102 ms
39,148 KB |
testcase_119 | AC | 102 ms
38,912 KB |
testcase_120 | AC | 101 ms
38,460 KB |
testcase_121 | AC | 105 ms
38,848 KB |
testcase_122 | AC | 104 ms
38,864 KB |
testcase_123 | AC | 106 ms
39,116 KB |
ソースコード
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(); } }