結果
問題 | No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1) |
ユーザー | ks2m |
提出日時 | 2021-11-05 21:33:33 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 123 ms / 2,000 ms |
コード長 | 975 bytes |
コンパイル時間 | 2,653 ms |
コンパイル使用メモリ | 77,976 KB |
実行使用メモリ | 54,460 KB |
最終ジャッジ日時 | 2024-04-24 05:20:25 |
合計ジャッジ時間 | 5,178 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 111 ms
54,460 KB |
testcase_01 | AC | 108 ms
54,228 KB |
testcase_02 | AC | 96 ms
52,916 KB |
testcase_03 | AC | 106 ms
53,908 KB |
testcase_04 | AC | 107 ms
53,980 KB |
testcase_05 | AC | 106 ms
53,888 KB |
testcase_06 | AC | 96 ms
53,068 KB |
testcase_07 | AC | 98 ms
52,908 KB |
testcase_08 | AC | 105 ms
52,784 KB |
testcase_09 | AC | 104 ms
53,004 KB |
testcase_10 | AC | 112 ms
54,324 KB |
testcase_11 | AC | 111 ms
54,164 KB |
testcase_12 | AC | 120 ms
53,948 KB |
testcase_13 | AC | 113 ms
54,204 KB |
testcase_14 | AC | 111 ms
54,056 KB |
testcase_15 | AC | 107 ms
54,096 KB |
testcase_16 | AC | 115 ms
54,172 KB |
testcase_17 | AC | 123 ms
54,188 KB |
testcase_18 | AC | 101 ms
53,032 KB |
testcase_19 | AC | 99 ms
53,176 KB |
testcase_20 | AC | 104 ms
53,580 KB |
testcase_21 | AC | 108 ms
54,024 KB |
testcase_22 | AC | 97 ms
52,976 KB |
testcase_23 | AC | 106 ms
54,100 KB |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); char[] s = sc.next().toCharArray(); sc.close(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length; i++) { int a = Integer.parseInt(String.valueOf(s[i]), 16); sb.append(Integer.toBinaryString(a)); } int[] cnt = new int[8]; int start = sb.length() % 3; if (start != 0) { int a = Integer.parseInt(sb.substring(0, start), 2); cnt[a]++; } for (int i = start; i < sb.length(); i += 3) { int a = Integer.parseInt(sb.substring(i, i + 3), 2); cnt[a]++; } int max = 0; for (int i = 0; i < cnt.length; i++) { max = Math.max(max, cnt[i]); } StringBuilder sb2 = new StringBuilder(); for (int i = 0; i < cnt.length; i++) { if (cnt[i] == max) { sb2.append(i).append(' '); } } sb2.deleteCharAt(sb2.length() - 1); System.out.println(sb2.toString()); } }