結果

問題 No.2118 遺伝的有限集合の数え上げ
ユーザー kakel-sankakel-san
提出日時 2022-11-04 22:22:15
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 2,299 ms
コンパイル使用メモリ 103,808 KB
実行使用メモリ 17,920 KB
最終ジャッジ日時 2024-07-18 20:16:36
合計ジャッジ時間 4,591 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 37
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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

class Program
{
    static int NN => int.Parse(ReadLine());
    static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        WriteLine(string.Concat(Sn(n)));
    }
    static List<char> Sn(int n)
    {
        var list = new List<char>();
        list.Add('{');
        var bit = 0;
        var isFirst = true;
        while ((1 << bit) <= n)
        {
            if (((1 << bit) & n) != 0)
            {
                if (!isFirst) list.Add(',');
                isFirst = false;
                list.AddRange(Sn(bit));
            }
            ++bit;
        }
        list.Add('}');
        return list;
    }
}
0