結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー |
|
提出日時 | 2018-05-18 23:13:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,767 bytes |
コンパイル時間 | 767 ms |
コンパイル使用メモリ | 96,928 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 13:36:01 |
合計ジャッジ時間 | 1,308 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <iomanip> #include <vector> #include <map> #include <cmath> #include <queue> #include <utility> #include <functional> #include <deque> #include <cctype> #include <stack> #include <bitset> #include <set> using namespace std; using ll = long long; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef pair<ll, pair<ll, ll>> PP; const ll MOD = 1e9 + 7; const ll INF = 1 << 30; const ll INF2 = 9e18; const double INF3 = 9e14; const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 }; const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 }; #define ALL(x) (x).begin(),(x).end() #define pb push_back #define fr first #define sc second ll rr(ll p) { int cnt = 0; if (p == 1)return INF; while (p > 1) { if (p % 2 == 1)return 0; p /= 2; cnt++; } return cnt; } int main() { ll k; cin >> k; if (k == 0) { cout << 1 << endl; cout << 1 << endl; return 0; } if (k == 1) { cout << 2 << endl; cout << 1 << ' ' << 1 << endl; return 0; } if (k == 435) { cout << 30 << endl; for (int i = 0;i < 30;i++)cout << 1 << ' '; return 0; } for (ll i = 2;i <= 30;i++) { if (k % (i*(i - 1) / 2) == 0 && rr(k / ((i*(i - 1)) / 2)) && (rr(k / ((i*(i - 1)) / 2)) <= 30 - i || rr(k / ((i*(i - 1)) / 2)) == INF)) { if (rr(k / ((i*(i - 1)) / 2)) == INF) { int p = 0; cout << i + p << endl; for (int j = 0;j < i;j++)cout << 1 << ' '; for (int j = 0;j < p;j++)cout << 0 << ' '; cout << endl; return 0; } else { cout << i + rr(k / ((i*(i - 1) / 2))) << endl; for (int j = 0;j < i;j++)cout << 1 << ' '; for (int j = 0;j < rr(k / ((i*(i - 1) / 2)));j++)cout << 0 << ' '; cout << endl; return 0; } } } return 0; }