結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 26 ms
8,500 KB
testcase_02 AC 113 ms
8,848 KB
testcase_03 WA -
testcase_04 AC 16 ms
8,288 KB
testcase_05 AC 17 ms
8,292 KB
testcase_06 AC 16 ms
8,396 KB
testcase_07 WA -
testcase_08 AC 16 ms
8,364 KB
testcase_09 AC 16 ms
8,432 KB
testcase_10 AC 16 ms
8,368 KB
testcase_11 AC 16 ms
8,360 KB
testcase_12 AC 17 ms
8,284 KB
testcase_13 AC 16 ms
8,348 KB
testcase_14 AC 16 ms
8,420 KB
testcase_15 AC 16 ms
8,412 KB
testcase_16 AC 16 ms
8,288 KB
testcase_17 AC 16 ms
8,360 KB
testcase_18 AC 16 ms
8,304 KB
testcase_19 AC 17 ms
8,284 KB
testcase_20 AC 16 ms
8,360 KB
testcase_21 AC 17 ms
8,416 KB
testcase_22 AC 17 ms
8,308 KB
testcase_23 AC 16 ms
8,384 KB
testcase_24 AC 16 ms
8,396 KB
testcase_25 AC 16 ms
8,288 KB
testcase_26 AC 16 ms
8,376 KB
testcase_27 AC 16 ms
8,284 KB
testcase_28 AC 16 ms
8,436 KB
testcase_29 AC 17 ms
8,368 KB
testcase_30 AC 17 ms
8,488 KB
testcase_31 AC 16 ms
8,300 KB
testcase_32 AC 16 ms
8,352 KB
testcase_33 AC 17 ms
8,344 KB
testcase_34 AC 65 ms
8,604 KB
testcase_35 AC 113 ms
8,896 KB
testcase_36 AC 19 ms
8,376 KB
testcase_37 AC 700 ms
12,300 KB
testcase_38 AC 34 ms
8,044 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