結果

問題 No.688 E869120 and Constructing Array 2
ユーザー kuuso1kuuso1
提出日時 2018-05-19 05:13:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 723 bytes
コンパイル時間 1,423 ms
コンパイル使用メモリ 163,404 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 20:25:58
合計ジャッジ時間 2,411 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	ll K;
	cin >> K;
	
	if(K == 0){
		cout << "14" << endl;
		cout << "0 0 0 0 0 0 0 1 0 0 0 0 0 0" << endl;
		return 0;
	}
	
	for(int i=2;i<=30;i++){
		ll b = i * (i - 1) / 2;
		for(int k=0;k<=30 - i;k++){
			if(b * (1 << k) == K){
				int N = i + k;
				printf("%d\n", N);
				for(int j=0;j<i;j++){
					if(j != 0) cout << " ";
					cout << "1";
				}
				for(int j=0;j<k;j++){
					cout << " 0";
				}
				cout << endl;
				return 0;
				
			}
		}
		
		
	}
	
	
	
    return 0;
}
0