結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー 👑 kakel-sankakel-san
提出日時 2021-11-05 21:43:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,358 bytes
コンパイル時間 1,039 ms
コンパイル使用メモリ 70,640 KB
実行使用メモリ 23,572 KB
最終ジャッジ日時 2023-08-06 09:30:49
合計ジャッジ時間 3,547 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
23,548 KB
testcase_01 AC 58 ms
23,536 KB
testcase_02 AC 58 ms
23,544 KB
testcase_03 AC 58 ms
21,496 KB
testcase_04 AC 58 ms
19,588 KB
testcase_05 AC 58 ms
21,652 KB
testcase_06 AC 57 ms
19,508 KB
testcase_07 AC 58 ms
21,408 KB
testcase_08 AC 57 ms
21,580 KB
testcase_09 AC 58 ms
23,536 KB
testcase_10 AC 57 ms
21,516 KB
testcase_11 AC 58 ms
21,580 KB
testcase_12 AC 57 ms
23,572 KB
testcase_13 AC 58 ms
21,596 KB
testcase_14 AC 58 ms
21,524 KB
testcase_15 AC 58 ms
21,632 KB
testcase_16 AC 58 ms
21,448 KB
testcase_17 AC 58 ms
21,688 KB
testcase_18 AC 60 ms
23,536 KB
testcase_19 AC 57 ms
21,480 KB
testcase_20 AC 57 ms
19,540 KB
testcase_21 AC 57 ms
21,420 KB
testcase_22 AC 58 ms
23,520 KB
testcase_23 AC 57 ms
21,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class yuki321
{
    static int NN => int.Parse(ReadLine());
    static string[] SList(int n) => Enumerable.Repeat(0, n).Select(_ => ReadLine()).ToArray();
    static void Main()
    {
        var n = ReadLine();
        var list = new List<int>();
        foreach (var ni in n)
        {
            list.AddRange(ToBin(ni - 'A' + 10));
        }
        var counts = new int[8];
        for (var e = list.Count; e > 0; e -= 3)
        {
            var s = Math.Max(0, e - 3);
            ++counts[FromBin(list.Skip(s).Take(e - s).ToList())];
        }
        var res = new List<int>();
        var maxcount = counts.Max();
        for (var i = 0; i < counts.Length; ++i) if (counts[i] == maxcount) res.Add(i);
        WriteLine(string.Join(" ", res));
    }
    static List<int> ToBin(int a)
    {
        var list = new List<int>();
        var tmp = a;
        for (var i = 0; i < 4; ++i)
        {
            list.Add(tmp % 2);
            tmp >>= 1;
        }
        list.Reverse();
        return list;
    }
    static int FromBin(List<int> list)
    {
        var num = 0;
        foreach (var li in list)
        {
            num <<= 1;
            num += li;
        }
        return num;
    }
}
0