結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 25 ms
8,468 KB
testcase_02 AC 117 ms
8,744 KB
testcase_03 WA -
testcase_04 AC 16 ms
8,268 KB
testcase_05 AC 15 ms
8,360 KB
testcase_06 AC 15 ms
8,440 KB
testcase_07 WA -
testcase_08 AC 16 ms
8,412 KB
testcase_09 AC 16 ms
8,240 KB
testcase_10 AC 16 ms
8,260 KB
testcase_11 AC 16 ms
8,360 KB
testcase_12 AC 15 ms
8,356 KB
testcase_13 AC 15 ms
8,436 KB
testcase_14 AC 15 ms
8,364 KB
testcase_15 AC 16 ms
8,296 KB
testcase_16 AC 15 ms
8,296 KB
testcase_17 AC 15 ms
8,416 KB
testcase_18 AC 16 ms
8,444 KB
testcase_19 AC 16 ms
8,476 KB
testcase_20 AC 15 ms
8,300 KB
testcase_21 AC 15 ms
8,364 KB
testcase_22 AC 16 ms
8,360 KB
testcase_23 AC 16 ms
8,308 KB
testcase_24 AC 15 ms
8,268 KB
testcase_25 AC 15 ms
8,360 KB
testcase_26 AC 16 ms
8,312 KB
testcase_27 AC 15 ms
8,416 KB
testcase_28 AC 15 ms
8,416 KB
testcase_29 AC 15 ms
8,368 KB
testcase_30 AC 16 ms
8,376 KB
testcase_31 AC 15 ms
8,368 KB
testcase_32 AC 15 ms
8,364 KB
testcase_33 AC 15 ms
8,316 KB
testcase_34 AC 64 ms
8,608 KB
testcase_35 AC 114 ms
8,856 KB
testcase_36 AC 18 ms
8,280 KB
testcase_37 AC 689 ms
12,316 KB
testcase_38 AC 31 ms
8,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt


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])


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


def permutation(num_list, current_list):
    result_list = []
    if num_list == []:
        return [current_list]
        # result_list.append(current_list)
    for i in range(len(num_list)):
        each_list = num_list.copy()
        each_list.pop(i)
        result_list = result_list + permutation(each_list, current_list + [num_list[i]])
    return result_list


n = int(input())
candidate = square_number_list(n, [])
candidates = permutation(candidate, [])
binary_strings = list(map(make_candidate_binary, candidates))

print(sorted(binary_strings)[0])
0