結果

問題 No.688 E869120 and Constructing Array 2
ユーザー uma-pinehilluma-pinehill
提出日時 2018-05-22 18:03:09
言語 C#(csc)
(csc 3.9.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 881 bytes
コンパイル時間 5,057 ms
コンパイル使用メモリ 104,428 KB
実行使用メモリ 24,772 KB
最終ジャッジ日時 2023-09-21 20:41:08
合計ジャッジ時間 5,142 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 58 ms
20,804 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 55 ms
22,644 KB
testcase_10 AC 58 ms
20,780 KB
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Text;
public class Program
{
    static void Main()
    {
        long K = long.Parse(Console.ReadLine());
        int ZeroCount = 0;
        
        if (K == 0){
            Console.WriteLine(1);
            Console.WriteLine(1);
            return;
        }
        
        while(K % 2 == 0){
           K = K / 2;
           ZeroCount++;
        }
        
        while(Math.Sqrt(K*8 + 1) % 1.0f != 0 || ((Math.Sqrt(K*8 + 1) + 1) / 2) % 1.0f != 0){
           K = K *2;
           ZeroCount--;
        }
        var OneCount = (int)((Math.Sqrt(K*8 + 1) + 1) / 2);
    
        
        Console.WriteLine(OneCount + ZeroCount);
        var x = new char[OneCount + ZeroCount];
        for(var i = OneCount + ZeroCount -1;i>=0;i--){
            x[i]= i < OneCount ? '0': '1';
        }
        
        Console.WriteLine(string.Join(" ",x));
    }
}
0