結果

問題 No.873 バイナリ、ヤバいなり!w
コンテスト
ユーザー LMMP
提出日時 2019-09-04 15:53:48
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 708 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 551 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 15,612 KB
最終ジャッジ日時 2026-03-10 05:50:27
合計ジャッジ時間 5,006 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 10 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import sqrt

n = int(input())


def square_number_list(n, current_list):
    if n == 0:
        return current_list
    base = int(sqrt(n))
    if base == sqrt(n):
        return current_list + [base]
    else:
        return square_number_list(n - base * base, current_list + [base])


candidate = square_number_list(n, [])


def make_candidate_binary(candidate):
    current_binary = 0
    current_string = ""
    for number in candidate:
        for i in range(0, number):
            current_string += str(current_binary)
            if i < number - 1:
                current_binary = 0 if current_binary == 1 else 1
    return current_string


print("".join(make_candidate_binary(candidate)))
0