結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー pirozhki
提出日時 2019-10-10 12:00:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 989 ms
コンパイル使用メモリ 87,980 KB
最終ジャッジ日時 2025-01-07 21:25:44
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 10 WA * 26
権限があれば一括ダウンロードができます

ソースコード

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