結果

問題 No.1732 ~サンプルはちゃんと見て!~ 16進数と8進数(2)
ユーザー 👑 kakel-sankakel-san
提出日時 2021-11-05 23:27:26
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,981 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 107,392 KB
実行使用メモリ 29,444 KB
最終ジャッジ日時 2024-04-24 07:25:06
合計ジャッジ時間 1,760 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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

class yuki321
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static void Main()
    {
        var t = NN;
        var str = "CCCFACCFAACCCCBACCCBA";
        var list = new List<int>(new[] { 0, 5, 10 });
        var reslist = new List<string>();
        for (var i = 0; i < t; ++i)
        {
            var n = NN;
            if (!list.Contains(n % 21))
            {
                reslist.Add("-1");
                continue;
            }
            var res = string.Concat(Enumerable.Repeat(str, (n + 20) / 21)).Take(n).ToList();
            res.Reverse();
            reslist.Add(string.Concat(res));
            Check(res);
        }
        WriteLine(string.Join("\n", reslist));
    }
    static void Check(List<char> n)
    {
        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