結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー pirozhkipirozhki
提出日時 2019-10-10 12:00:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 835 ms
コンパイル使用メモリ 86,196 KB
実行使用メモリ 5,348 KB
最終ジャッジ日時 2023-08-13 03:45:30
合計ジャッジ時間 2,395 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> v;
	for (int i = int(sqrt(n)); i > 0; i--) {
		vector<int> w;
		for (int j = i, m = n; m != 0;) {
			if (m - j * j < 0) {
				j--;
			}
			else {
				w.push_back(j);
				m -= j * j;
			}
		}
		if (i == int(sqrt(n)) || w.size() < v.size()) {
			v = w;
		}
	}
	string s = "0";
	for (const int& l : v) {
		for (int i = 1; i < l; i++) {
			if (s.back() == '0') s += '1';
			else s += '0';
		}
		s += s.back();
	}
	s.pop_back();
	cout << s << endl;
	return 0;
}
0