結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー LMMPLMMP
提出日時 2019-09-04 15:53:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 708 bytes
コンパイル時間 78 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 8,128 KB
最終ジャッジ日時 2023-09-06 12:01:11
合計ジャッジ時間 1,996 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 16 ms
7,980 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 15 ms
7,944 KB
testcase_09 AC 16 ms
7,952 KB
testcase_10 AC 16 ms
8,036 KB
testcase_11 AC 16 ms
7,944 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 15 ms
7,988 KB
testcase_16 AC 15 ms
7,984 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 16 ms
7,948 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 15 ms
7,928 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 15 ms
7,920 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 15 ms
7,920 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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