結果

問題 No.873 バイナリ、ヤバいなり!w
ユーザー leaf_1415leaf_1415
提出日時 2019-08-30 22:02:58
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 893 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 69,720 KB
実行使用メモリ 814,592 KB
最終ジャッジ日時 2023-09-06 06:53:15
合計ジャッジ時間 4,475 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
	for(int i = 0; i*i <= n; i++) dp[i*i] = i, pre[i*i] = i;
	
	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