結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー bluemeganebluemegane
提出日時 2021-11-06 10:16:23
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,323 bytes
コンパイル時間 1,984 ms
コンパイル使用メモリ 67,864 KB
実行使用メモリ 23,532 KB
最終ジャッジ日時 2023-08-07 02:03:14
合計ジャッジ時間 4,711 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
21,456 KB
testcase_01 AC 64 ms
21,328 KB
testcase_02 AC 65 ms
21,440 KB
testcase_03 AC 64 ms
21,328 KB
testcase_04 AC 65 ms
23,532 KB
testcase_05 AC 65 ms
21,276 KB
testcase_06 AC 65 ms
21,244 KB
testcase_07 AC 64 ms
19,332 KB
testcase_08 AC 63 ms
21,272 KB
testcase_09 AC 63 ms
21,288 KB
testcase_10 AC 63 ms
21,288 KB
testcase_11 AC 64 ms
21,404 KB
testcase_12 AC 63 ms
21,324 KB
testcase_13 AC 65 ms
19,356 KB
testcase_14 AC 64 ms
21,248 KB
testcase_15 AC 64 ms
21,392 KB
testcase_16 AC 65 ms
21,336 KB
testcase_17 AC 65 ms
21,392 KB
testcase_18 AC 64 ms
23,340 KB
testcase_19 AC 65 ms
19,292 KB
testcase_20 AC 63 ms
21,328 KB
testcase_21 AC 64 ms
21,324 KB
testcase_22 AC 64 ms
21,292 KB
testcase_23 AC 63 ms
19,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Hello
{
    public static Dictionary<char, string> d;
    public static Dictionary<string, int> d2;
    static void Main()
    {
        d = new Dictionary<char, string>();
        d2 = new Dictionary<string, int>();
        var a = "ABCDEF";
        foreach (var x in a)
        {
            var xx = x.ToString();
            d[x] = Convert.ToString(Convert.ToInt32(xx, 16), 2);
        }
        for (int i = 0; i < 8; i++)
        {
            var w = Convert.ToString(i, 2);
            d2[new string('0', 3 - w.Length) + w] = i;
        }
        var s = Console.ReadLine().Trim();
        getAns(s);
    }
    static void getAns(string s)
    {
        var ss = "";
        foreach (var x in s) ss += d[x];
        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[d2[ww]]++;
            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