結果

問題 No.688 E869120 and Constructing Array 2
ユーザー bluemeganebluemegane
提出日時 2018-09-06 15:25:52
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 1,000 ms
コード長 775 bytes
コンパイル時間 1,112 ms
コンパイル使用メモリ 63,320 KB
実行使用メモリ 23,200 KB
最終ジャッジ日時 2023-08-14 08:47:51
合計ジャッジ時間 2,826 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
23,012 KB
testcase_01 AC 57 ms
21,200 KB
testcase_02 AC 56 ms
21,200 KB
testcase_03 AC 60 ms
21,280 KB
testcase_04 AC 58 ms
19,236 KB
testcase_05 AC 58 ms
21,208 KB
testcase_06 AC 58 ms
23,160 KB
testcase_07 AC 56 ms
21,112 KB
testcase_08 AC 57 ms
21,192 KB
testcase_09 AC 54 ms
20,716 KB
testcase_10 AC 58 ms
20,880 KB
testcase_11 AC 58 ms
21,268 KB
testcase_12 AC 57 ms
23,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class Hello
{
    public static void Main()
    {
        var k = int.Parse(Console.ReadLine().Trim());
        if (k == 0) { Console.WriteLine(1); Console.WriteLine(1); goto end; }
        if (k == 1) { Console.WriteLine(2); Console.WriteLine("1 1"); goto end; }
        for (int i = 2; i <= 30; i++)
        {
            for (int j = 0; j <= i-2; j++)
            {
                var w = Math.Pow(2, j) * ((i - j) * (i - j - 1) / 2);
                if (w == k) { putAns(i, j); goto end; }
            }
        }
        end:;
    }
    public static void putAns (int i, int j)
    {
        Console.WriteLine(i);
        var a = new int[i];
        for (int x = 0; x < i - j; x++) a[x] = 1;
        Console.WriteLine(string.Join(" ",a));
    }
}
0