結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー bluemeganebluemegane
提出日時 2021-11-06 10:43:19
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 911 bytes
コンパイル時間 1,861 ms
コンパイル使用メモリ 69,816 KB
実行使用メモリ 23,464 KB
最終ジャッジ日時 2023-08-07 02:46:39
合計ジャッジ時間 3,833 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
21,368 KB
testcase_01 AC 57 ms
23,312 KB
testcase_02 AC 57 ms
23,340 KB
testcase_03 AC 56 ms
21,288 KB
testcase_04 AC 55 ms
19,304 KB
testcase_05 AC 55 ms
21,164 KB
testcase_06 AC 55 ms
21,236 KB
testcase_07 AC 57 ms
21,292 KB
testcase_08 AC 56 ms
21,284 KB
testcase_09 AC 56 ms
21,272 KB
testcase_10 AC 56 ms
21,248 KB
testcase_11 AC 55 ms
21,392 KB
testcase_12 AC 55 ms
21,264 KB
testcase_13 AC 56 ms
23,292 KB
testcase_14 AC 58 ms
23,384 KB
testcase_15 AC 57 ms
21,300 KB
testcase_16 AC 58 ms
21,424 KB
testcase_17 AC 57 ms
21,264 KB
testcase_18 AC 57 ms
21,372 KB
testcase_19 AC 56 ms
19,288 KB
testcase_20 AC 56 ms
21,308 KB
testcase_21 AC 56 ms
21,248 KB
testcase_22 AC 57 ms
23,464 KB
testcase_23 AC 56 ms
21,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    static void Main()
    {
        var s = Console.ReadLine().Trim();
        getAns(s);
    }
    static void getAns(string s)
    {
        var ss = "";
        foreach (var x in s)
        {
            ss += Convert.ToString(Convert.ToInt32(x.ToString(), 16), 2);
        }
        var ans = new int[8];
        var ssL = ss.Length;
        var sub = ssL % 3;
        var w1 = ss.Substring(0, sub);
        if (sub != 0) ans[Convert.ToInt32(w1, 2)]++;
        var p = sub;
        while (p < ssL)
        {
            var ww = ss.Substring(p, 3);
            ans[Convert.ToInt32(ww, 2)]++;
            p += 3;
        }
        var res = new List<int>();
        var ansmax = ans.Max();
        for (int i = 0; i < 8; i++) if (ans[i] == ansmax) res.Add(i);
        Console.WriteLine(string.Join(" ", res));
    }
}
0