結果

問題 No.688 E869120 and Constructing Array 2
ユーザー amtgjwamtgjw
提出日時 2018-05-22 16:53:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 831 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 72,144 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-21 20:37:47
合計ジャッジ時間 1,496 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,500 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <complex>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

#define INF 		2000000007
#define MOD			1000000007

#define MAX 		200005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

int dp[32];

int main(){
	int K;cin>>K;
	if(K==0){
		cout << 0 << endl << endl;
		return 0;
	}

	int a=0,b=0;
	int N=K;
	while(K%2==0){
		K/=2;
		a++;
	}

	REPS(i,2,31){
		dp[i] = i*(i-1)/2;
	}

	REP(i,30){
		REP(j,31)
			if(dp[j]==K){
				b=j;
				break;
			}
		if(b > 0) break;
		K*=2;
		--a;
	}


	cout << (a+b) << endl;
	REP(i,a) cout << 0 << " ";
	REP(i,b) cout << 1 << " ";
	cout << endl;

	return 0;
}
0