結果
| 問題 |
No.688 E869120 and Constructing Array 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-22 18:03:09 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 881 bytes |
| コンパイル時間 | 966 ms |
| コンパイル使用メモリ | 104,704 KB |
| 実行使用メモリ | 17,792 KB |
| 最終ジャッジ日時 | 2024-07-07 14:06:07 |
| 合計ジャッジ時間 | 3,527 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 2 WA * 8 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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));
}
}