結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー |
![]() |
提出日時 | 2018-05-18 22:35:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,597 bytes |
コンパイル時間 | 880 ms |
コンパイル使用メモリ | 98,460 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 13:26:24 |
合計ジャッジ時間 | 1,804 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#define _CRT_SECURE_NO_WARNiINGS#include <stdio.h>#include <algorithm>#include <utility>#include <functional>#include <cstring>#include <queue>#include <stack>#include <math.h>#include <iterator>#include <vector>#include <string>#include <set>#include <math.h>#include <iostream>#include <random>#include <map>#include <fstream>#include <iomanip>#include <time.h>#include <stdlib.h>#include <list>#include <typeinfo>#include <list>#include <cassert>#include <set>using namespace std;#define eps 0.000000001#define LONG_INF 10000000000000000#define GOLD 1.61803398874989484820458#define MAX_MOD 1000000007#define REP(i,n) for(long long i = 0;i < n;++i)#define cycle_per_sec 2806192512int main() {long long k;cin >> k;if (k == 0) {cout << "1" << endl;cout << 1 << endl;return 0;}vector<int> answer;for (int i = 0;true; ++i) {long long top = 40;long long bot = 0;while (top - bot > 1) {long long mid = (top + bot) / 2;long long geko = mid * (mid - 1LL);if (geko/2LL >= k) {top = mid;}else {bot = mid;}}if ((bot) * (bot - 1LL)/2LL == k) {if (answer.size() + bot <= 30) {for (int q = 0; q < bot; ++q) {answer.push_back(1);}break;}}else if (top * (top - 1LL)/2LL == k) {if (answer.size() + top <= 30) {for (int q = 0; q < top; ++q) {answer.push_back(1);}break;}}k /= 2;answer.push_back(0);}cout << answer.size() << endl;for (int i = 0; i < answer.size(); ++i) {cout << answer[i] << " ";}cout << endl;return 0;}