結果
問題 |
No.873 バイナリ、ヤバいなり!w
|
ユーザー |
![]() |
提出日時 | 2019-09-04 16:56:56 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,160 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 14,720 KB |
最終ジャッジ日時 | 2024-06-24 06:38:46 |
合計ジャッジ時間 | 3,537 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 34 WA * 2 |
ソースコード
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])