結果

問題 No.688 E869120 and Constructing Array 2
ユーザー keymoonkeymoon
提出日時 2018-05-18 22:51:38
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 981 bytes
コンパイル時間 1,432 ms
コンパイル使用メモリ 106,624 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-07-07 13:32:22
合計ジャッジ時間 2,808 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
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