結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 15 ms
7,908 KB
testcase_06 AC 15 ms
8,040 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 15 ms
8,060 KB
testcase_10 AC 15 ms
7,912 KB
testcase_11 AC 15 ms
7,916 KB
testcase_12 AC 15 ms
7,932 KB
testcase_13 AC 15 ms
8,012 KB
testcase_14 AC 15 ms
8,036 KB
testcase_15 AC 15 ms
7,980 KB
testcase_16 AC 15 ms
8,008 KB
testcase_17 AC 15 ms
8,032 KB
testcase_18 AC 16 ms
8,004 KB
testcase_19 AC 15 ms
8,036 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 15 ms
7,964 KB
testcase_24 AC 15 ms
8,084 KB
testcase_25 AC 16 ms
7,916 KB
testcase_26 AC 15 ms
7,956 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 16 ms
7,956 KB
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

candidate.reverse()

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