結果
| 問題 |
No.688 E869120 and Constructing Array 2
|
| ユーザー |
|
| 提出日時 | 2018-05-18 22:42:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 791 bytes |
| コンパイル時間 | 1,558 ms |
| コンパイル使用メモリ | 166,672 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 13:28:31 |
| 合計ジャッジ時間 | 2,289 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;
int main(){
int n; cin >> n;
if(n == 0){
cout << 1 << endl;
return 0;
}
int a = 0, x = n;
while(x % 2 == 0){
x /= 2;
a++;
}
if(x == 1){
cout << a + 2 << endl;
for(int i = 0; i < a; i++) cout << 0 << " ";
cout << 1 << " " << 1 << endl;
return 0;
}
for(int i = 2; i * (i + 1) / 2 <= n; i++){
if(n % (i * (i + 1) / 2)) continue;
int B = i + 1;
int pos = n / ((i * (i + 1)) / 2);
int A = 0;
while(pos % 2 == 0){
pos /= 2;
A++;
}
if(pos != 1) continue;
if(A + B > 30) continue;
cout << A + B << endl;
for(int i = 0; i < A; i++) cout << 0 << " ";
for(int i = 0; i < B; i++) cout << 1 << " ";
cout << endl;
return 0;
}
assert(false);
return 0;
}