結果

問題 No.688 E869120 and Constructing Array 2
ユーザー kotatsugame
提出日時 2018-06-15 03:04:41
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 367 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 65,008 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 14:18:11
合計ジャッジ時間 1,040 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int k;
main()
{
	cin>>k;
	if(k==0)
	{
		cout<<"1\n0\n";
		return 0;
	}
	for(int i=2;;i++)
	{
		int n=i*(i-1)/2;
		if(k%n==0&&__builtin_popcount(k/n)==1)
		{
			int l=__builtin_ctz(k/n);
			cout<<i+l<<endl;
			cout<<1;
			for(int j=0;j<i-1;j++)cout<<" 1";
			for(int j=0;j<l;j++)cout<<" 0";
			cout<<endl;
			return 0;
		}
	}
}
0