結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー ripityripity
提出日時 2021-11-06 00:45:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 970 bytes
コンパイル時間 2,980 ms
コンパイル使用メモリ 75,980 KB
実行使用メモリ 56,204 KB
最終ジャッジ日時 2023-08-06 14:30:28
合計ジャッジ時間 7,317 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,800 KB
testcase_01 AC 140 ms
55,580 KB
testcase_02 AC 138 ms
55,728 KB
testcase_03 AC 138 ms
55,952 KB
testcase_04 AC 138 ms
56,020 KB
testcase_05 AC 136 ms
55,708 KB
testcase_06 AC 136 ms
55,848 KB
testcase_07 AC 134 ms
55,620 KB
testcase_08 AC 142 ms
56,204 KB
testcase_09 AC 147 ms
55,564 KB
testcase_10 AC 144 ms
55,960 KB
testcase_11 AC 139 ms
55,712 KB
testcase_12 AC 143 ms
55,776 KB
testcase_13 AC 143 ms
55,564 KB
testcase_14 AC 136 ms
55,776 KB
testcase_15 AC 136 ms
53,668 KB
testcase_16 AC 145 ms
56,120 KB
testcase_17 AC 142 ms
56,008 KB
testcase_18 AC 143 ms
56,012 KB
testcase_19 AC 137 ms
55,612 KB
testcase_20 AC 136 ms
56,048 KB
testcase_21 AC 138 ms
55,900 KB
testcase_22 AC 140 ms
55,636 KB
testcase_23 AC 135 ms
55,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String bin = "";
        int[] cnt = new int[8];
        for( int i = 0; i < s.length(); i++ ) {
            String ch = s.substring(i,i+1);
            int d = Integer.parseInt(ch,16);
            String ad = Integer.toString(d,2);
            bin += ad;
        }
        
        for( int i = bin.length(); i > 0; i-=3 ){
            String row = bin.substring(Math.max(0,i-3),i);
            int k = Integer.parseInt(row,2);
            cnt[k]++;
        }
        
        int max = 0;
        for( int i = 0; i < 8; i++ ) {
            max = Math.max(max,cnt[i]);
        }
        
        for( int i = 0; i < 8; i++ ) {
            if( cnt[i] == max ) {
                System.out.print(i+" ");
            }
        }
        
        System.out.println();
        
    }
    
}
0