結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー leaf_1415leaf_1415
提出日時 2019-08-30 22:07:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 847 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 69,624 KB
実行使用メモリ 8,272 KB
最終ジャッジ日時 2023-09-06 06:57:54
合計ジャッジ時間 2,975 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <utility>
#include <algorithm>
#include <queue>
#include <vector>
#define llint long long

using namespace std;

llint n;
llint dp[300005], pre[300005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 0; i <= n; i++) dp[i] = 1e9;
	dp[0] = 0;
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j*j <= i; j++){
			if(dp[i] > dp[i-j*j]+j){
				dp[i] = dp[i-j*j]+j;
				pre[i] = j;
			}
		}
	}
	
	llint p = n;
	vector<llint> vec;
	while(p > 0){
		vec.push_back(pre[p]);
		p -= pre[p]*pre[p];
	}
	sort(vec.begin(), vec.end());
	
	string ans;
	for(int i = 0; i < vec.size(); i++){
		for(int j = 0; j < vec[i]; j++) ans += ('0' + (i%2));
	}
	for(int i = 0; i < ans.size(); i++){
		if(i%2){
			if(ans[i] == '0') ans[i] = '1';
			else ans[i] = '0';
		}
	}
	cout << ans << endl;
	
	return 0;
}
0