結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:14: warning: ‘b’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout << (a+b) << endl;
              ^

ソースコード

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[MAX];

int main(){
	int K;cin>>K;

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

	int b;
	while(K<N){
		double t = sqrt(1+8*K);
		if(ceil(t) == floor(t)){
			b = (t+1)/2;
			break;
		}
		K*=2;
		--a;
	}
	cout << (a+b) << endl;
	REP(i,a) cout << 0 << " ";
	REP(i,b) cout << 1 << " ";
	cout << endl;

	return 0;
}
0