結果

問題 No.688 E869120 and Constructing Array 2
ユーザー bluemeganebluemegane
提出日時 2018-09-06 15:30:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 1,000 ms
コード長 675 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 64,936 KB
実行使用メモリ 23,368 KB
最終ジャッジ日時 2023-08-14 08:55:55
合計ジャッジ時間 3,275 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,960 KB
testcase_01 AC 58 ms
21,212 KB
testcase_02 AC 58 ms
21,216 KB
testcase_03 AC 57 ms
21,256 KB
testcase_04 AC 58 ms
21,292 KB
testcase_05 AC 58 ms
23,320 KB
testcase_06 AC 58 ms
21,236 KB
testcase_07 AC 57 ms
23,208 KB
testcase_08 AC 58 ms
21,256 KB
testcase_09 AC 55 ms
20,716 KB
testcase_10 AC 58 ms
20,816 KB
testcase_11 AC 57 ms
21,224 KB
testcase_12 AC 58 ms
23,368 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; }
        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