結果

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

ソースコード

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

candidate.reverse()

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