結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー | kotamanegi |
提出日時 | 2018-05-18 22:35:48 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,597 bytes |
コンパイル時間 | 1,198 ms |
コンパイル使用メモリ | 96,196 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-21 19:54:05 |
合計ジャッジ時間 | 2,077 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,376 KB |
ソースコード
#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 2806192512 int 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; }