結果
問題 | No.747 循環小数N桁目 Hard |
ユーザー | tenten |
提出日時 | 2023-11-15 20:28:31 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 128 ms / 2,000 ms |
コード長 | 2,092 bytes |
コンパイル時間 | 2,331 ms |
コンパイル使用メモリ | 89,716 KB |
実行使用メモリ | 40,916 KB |
最終ジャッジ日時 | 2024-09-26 04:48:41 |
合計ジャッジ時間 | 15,144 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
37,136 KB |
testcase_01 | AC | 47 ms
37,180 KB |
testcase_02 | AC | 46 ms
36,808 KB |
testcase_03 | AC | 46 ms
37,144 KB |
testcase_04 | AC | 48 ms
36,696 KB |
testcase_05 | AC | 47 ms
36,848 KB |
testcase_06 | AC | 47 ms
36,580 KB |
testcase_07 | AC | 48 ms
36,736 KB |
testcase_08 | AC | 47 ms
37,180 KB |
testcase_09 | AC | 48 ms
37,376 KB |
testcase_10 | AC | 48 ms
36,944 KB |
testcase_11 | AC | 48 ms
36,604 KB |
testcase_12 | AC | 46 ms
37,180 KB |
testcase_13 | AC | 48 ms
36,472 KB |
testcase_14 | AC | 48 ms
37,152 KB |
testcase_15 | AC | 47 ms
37,144 KB |
testcase_16 | AC | 48 ms
37,072 KB |
testcase_17 | AC | 48 ms
37,084 KB |
testcase_18 | AC | 49 ms
36,944 KB |
testcase_19 | AC | 49 ms
36,792 KB |
testcase_20 | AC | 49 ms
37,120 KB |
testcase_21 | AC | 49 ms
37,236 KB |
testcase_22 | AC | 49 ms
37,048 KB |
testcase_23 | AC | 49 ms
37,016 KB |
testcase_24 | AC | 47 ms
37,296 KB |
testcase_25 | AC | 47 ms
36,736 KB |
testcase_26 | AC | 47 ms
37,152 KB |
testcase_27 | AC | 49 ms
36,820 KB |
testcase_28 | AC | 50 ms
37,216 KB |
testcase_29 | AC | 47 ms
37,076 KB |
testcase_30 | AC | 48 ms
37,204 KB |
testcase_31 | AC | 49 ms
37,020 KB |
testcase_32 | AC | 50 ms
36,588 KB |
testcase_33 | AC | 86 ms
38,728 KB |
testcase_34 | AC | 61 ms
37,376 KB |
testcase_35 | AC | 71 ms
37,820 KB |
testcase_36 | AC | 65 ms
37,812 KB |
testcase_37 | AC | 55 ms
37,124 KB |
testcase_38 | AC | 68 ms
37,960 KB |
testcase_39 | AC | 66 ms
38,184 KB |
testcase_40 | AC | 89 ms
39,192 KB |
testcase_41 | AC | 90 ms
39,344 KB |
testcase_42 | AC | 88 ms
39,052 KB |
testcase_43 | AC | 66 ms
37,504 KB |
testcase_44 | AC | 85 ms
39,120 KB |
testcase_45 | AC | 97 ms
39,064 KB |
testcase_46 | AC | 91 ms
39,220 KB |
testcase_47 | AC | 90 ms
38,656 KB |
testcase_48 | AC | 68 ms
37,704 KB |
testcase_49 | AC | 69 ms
37,804 KB |
testcase_50 | AC | 66 ms
37,816 KB |
testcase_51 | AC | 66 ms
38,048 KB |
testcase_52 | AC | 61 ms
37,832 KB |
testcase_53 | AC | 127 ms
40,272 KB |
testcase_54 | AC | 94 ms
38,952 KB |
testcase_55 | AC | 96 ms
39,668 KB |
testcase_56 | AC | 96 ms
39,152 KB |
testcase_57 | AC | 63 ms
37,876 KB |
testcase_58 | AC | 128 ms
40,916 KB |
testcase_59 | AC | 78 ms
38,716 KB |
testcase_60 | AC | 110 ms
39,292 KB |
testcase_61 | AC | 88 ms
39,056 KB |
testcase_62 | AC | 88 ms
39,076 KB |
testcase_63 | AC | 87 ms
39,328 KB |
testcase_64 | AC | 64 ms
37,912 KB |
testcase_65 | AC | 55 ms
37,184 KB |
testcase_66 | AC | 68 ms
37,772 KB |
testcase_67 | AC | 64 ms
37,668 KB |
testcase_68 | AC | 87 ms
38,912 KB |
testcase_69 | AC | 87 ms
39,048 KB |
testcase_70 | AC | 66 ms
37,632 KB |
testcase_71 | AC | 60 ms
37,704 KB |
testcase_72 | AC | 67 ms
37,504 KB |
testcase_73 | AC | 88 ms
39,228 KB |
testcase_74 | AC | 86 ms
39,248 KB |
testcase_75 | AC | 63 ms
37,928 KB |
testcase_76 | AC | 67 ms
37,920 KB |
testcase_77 | AC | 67 ms
37,804 KB |
testcase_78 | AC | 88 ms
38,864 KB |
testcase_79 | AC | 68 ms
37,872 KB |
testcase_80 | AC | 88 ms
38,772 KB |
testcase_81 | AC | 62 ms
37,888 KB |
testcase_82 | AC | 66 ms
37,732 KB |
testcase_83 | AC | 62 ms
37,780 KB |
testcase_84 | AC | 85 ms
39,224 KB |
testcase_85 | AC | 88 ms
39,152 KB |
testcase_86 | AC | 67 ms
38,120 KB |
testcase_87 | AC | 85 ms
39,120 KB |
testcase_88 | AC | 70 ms
37,908 KB |
testcase_89 | AC | 69 ms
37,992 KB |
testcase_90 | AC | 79 ms
38,912 KB |
testcase_91 | AC | 87 ms
38,976 KB |
testcase_92 | AC | 65 ms
37,856 KB |
testcase_93 | AC | 76 ms
38,280 KB |
testcase_94 | AC | 90 ms
39,380 KB |
testcase_95 | AC | 96 ms
39,592 KB |
testcase_96 | AC | 97 ms
39,500 KB |
testcase_97 | AC | 104 ms
39,272 KB |
testcase_98 | AC | 128 ms
40,156 KB |
testcase_99 | AC | 112 ms
39,576 KB |
testcase_100 | AC | 122 ms
39,756 KB |
testcase_101 | AC | 74 ms
38,316 KB |
testcase_102 | AC | 85 ms
39,040 KB |
testcase_103 | AC | 87 ms
39,168 KB |
testcase_104 | AC | 87 ms
39,168 KB |
testcase_105 | AC | 88 ms
39,372 KB |
testcase_106 | AC | 93 ms
39,108 KB |
testcase_107 | AC | 89 ms
39,344 KB |
testcase_108 | AC | 89 ms
39,296 KB |
testcase_109 | AC | 88 ms
39,356 KB |
testcase_110 | AC | 88 ms
39,304 KB |
testcase_111 | AC | 88 ms
39,504 KB |
testcase_112 | AC | 90 ms
39,372 KB |
testcase_113 | AC | 90 ms
39,144 KB |
testcase_114 | AC | 88 ms
39,192 KB |
testcase_115 | AC | 90 ms
39,340 KB |
testcase_116 | AC | 89 ms
39,268 KB |
testcase_117 | AC | 86 ms
39,356 KB |
testcase_118 | AC | 87 ms
39,480 KB |
testcase_119 | AC | 90 ms
39,464 KB |
testcase_120 | AC | 89 ms
39,276 KB |
testcase_121 | AC | 88 ms
39,460 KB |
testcase_122 | AC | 89 ms
38,944 KB |
testcase_123 | AC | 88 ms
39,176 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); char[] string = "285714".toCharArray(); int n = 0; for (char c : sc.next().toCharArray()) { n *= 10; n %= 6; n += c - '0'; n %= 6; } int idx = 1; char[] inputs = sc.next().toCharArray(); for (int i = inputs.length - 1; i >= 0; i--) { idx *= pow(n, inputs[i] - '0'); idx %= 6; n = pow(n, 10); } idx += 5; idx %= 6; System.out.println(string[idx]); } static int pow(int x, int p) { if (p == 0) { return 1; } else { return pow(x, p - 1) * x % 6; } } } 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(); } }