結果

問題 No.688 E869120 and Constructing Array 2
ユーザー niinii
提出日時 2018-05-18 22:53:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,357 bytes
コンパイル時間 984 ms
コンパイル使用メモリ 78,696 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 20:00:59
合計ジャッジ時間 1,429 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
//
int main(){
	int K;
	cin>>K;
	if(K==0){
		cout<<1<<endl;
		cout<<0<<endl;
		return 0;
	}else if(K==1){
		cout<<2<<endl;
		cout<<"1 1"<<endl;
		return 0;
	}
	int now=1;
	int num=2;
	while(1){
		int aa=K/now;
		if(K%now!=0){
			now+=num;
			num++;
			continue;
		}
		int cc=1;
		int bb=0;
		while(cc<aa){
			cc*=2;
			bb++;
		}
		if(cc!=aa){
			now+=num;
			num++;
			continue;
		}
		if(bb>=0&&bb<=30-num){
			cout<<bb+num<<endl;
			FOR(i,0,bb){
				if(i!=0){
					cout<<" ";
				}
				cout<<0;
			}
			FOR(i,0,num){
				cout<<" "<<1;
			}
			cout<<endl;
			return 0;
		}
		now+=num;
		num++;
	}
	return 0;
}
0