結果

問題 No.688 E869120 and Constructing Array 2
ユーザー ats5515
提出日時 2018-05-18 22:29:51
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
+ 823µs
コード長 744 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 514 ms
コンパイル使用メモリ 106,932 KB
実行使用メモリ 9,908 KB
最終ジャッジ日時 2026-10-31 09:23:31
合計ジャッジ時間 1,954 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int solve(int a1, int a0) {
	return ((int)1 << a0) * (a1 * (a1 - 1) / 2);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for (int i = 0; i <= 30; i++) {
		for (int j = 0; j <= 30; j++) {
			if (i+j>0 && i + j <= 30) {
				if (N == solve(i, j)) {
					cout << i + j << endl;
					for (int ii = 0; ii < i; ii++) {
						cout << 1 << " ";
					}
					for (int ii = 0; ii < j; ii++) {
						cout << 0 << " ";
					}
					cout << endl;
					return 0;
				}
			}
		}
	}

}
0