結果

問題 No.688 E869120 and Constructing Array 2
ユーザー keymoonkeymoon
提出日時 2018-05-18 22:51:38
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 62 ms / 1,000 ms
コード長 981 bytes
コンパイル時間 2,011 ms
コンパイル使用メモリ 103,352 KB
実行使用メモリ 23,668 KB
最終ジャッジ日時 2023-09-21 20:00:37
合計ジャッジ時間 3,641 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,560 KB
testcase_01 AC 61 ms
21,544 KB
testcase_02 AC 62 ms
21,576 KB
testcase_03 AC 62 ms
21,600 KB
testcase_04 AC 61 ms
21,688 KB
testcase_05 AC 60 ms
21,504 KB
testcase_06 AC 61 ms
21,708 KB
testcase_07 AC 61 ms
19,524 KB
testcase_08 AC 60 ms
21,548 KB
testcase_09 AC 54 ms
21,584 KB
testcase_10 AC 59 ms
23,668 KB
testcase_11 AC 58 ms
21,656 KB
testcase_12 AC 58 ms
21,500 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static List<long> pow = new List<long>(){ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912 };
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        if (n == 0) Console.WriteLine("1\n0");
        //1の数
        for (int i = 2; i <= 30; i++)
        {
            long p = (i * (i - 1) / 2);
            if (n % p != 0) continue;
            if (!pow.Contains(n / p)) continue;
            int index = pow.IndexOf(n / p);
            if (i + index > 30) continue;
            Console.WriteLine(index + i);
            Console.WriteLine(string.Join(" ", Enumerable.Repeat('1', i).Concat(Enumerable.Repeat('0', index))));
            return;
        }
    }
}
0