結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー |
|
提出日時 | 2018-05-18 22:29:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,108 bytes |
コンパイル時間 | 828 ms |
コンパイル使用メモリ | 101,856 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 06:50:28 |
合計ジャッジ時間 | 1,402 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#define _USE_MATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <array> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> using namespace std; int main() { int k; cin >> k; if(k == 0){ cout << 1 << endl << 0 << endl; return 0; } for(int x=2; ; ++x){ int tmp = x * (x - 1) / 2; if(k % tmp != 0) continue; tmp = k / tmp; int y = 0; while(tmp % 2 == 0){ tmp /= 2; ++ y; } if(tmp != 1 || x + y > 30) continue; cout << (x + y) << endl; cout << 1; for(int i=1; i<x; ++i) cout << ' ' << 1; for(int i=0; i<y; ++i) cout << ' ' << 0; cout << endl; return 0; } }