結果

問題 No.688 E869120 and Constructing Array 2
ユーザー bal4ubal4u
提出日時 2019-07-12 18:24:50
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 615 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 30,184 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 14:36:35
合計ジャッジ時間 2,032 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

// yukicoder: No.688 E869120 and Constructing Array 2
// 2019.7.12 bal4u

#include <stdio.h>
#include <math.h>

int sp;
void out(int n) {
	if (!sp) sp = 1; else putchar(' ');
	putchar('0'+n);
}

int calc(long long k) {
	int b = (int)sqrt((double)(1+(k<<2)));
	long long bb = (long long)b*b - 1;
	if (bb % 4 == 0 && bb / 4 == k) return (1+b) >> 1;
	return -1;
}

int main()
{
	int p, zero, one;
	long long K;
	
	scanf("%lld", &K);
	zero = 0, K <<= 1;
	while ((one = calc(K)) < 0 || zero+one > 30) zero++, K >>= 1;
	printf("%d\n", zero+one);
	while (zero--) out(0);
	while (one--) out(1);
	putchar('\n');
	return 0;
}
0