結果

問題 No.688 E869120 and Constructing Array 2
ユーザー SSRS
提出日時 2020-11-10 10:20:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 545 bytes
コンパイル時間 774 ms
コンパイル使用メモリ 69,760 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-22 17:19:36
合計ジャッジ時間 1,185 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
	int K;
	cin >> K;
	for (int x = 0; x <= 30; x++){
		for (int y = 0; y <= 30 - x; y++){
			if (((y * (y - 1) / 2) << x) == K && x + y > 0){
				vector<int> b;
				for (int i = 0; i < x; i++){
					b.push_back(0);
				}
				for (int i = 0; i < y; i++){
					b.push_back(1);
				}
				int N = b.size();
				cout << N << endl;
				for (int i = 0; i < N; i++){
					cout << b[i];
					if (i < N - 1){
						cout << ' ';
					}
				}
				cout << endl;
				return 0;
			}
		}
	}
}
0