結果
| 問題 |
No.688 E869120 and Constructing Array 2
|
| コンテスト | |
| ユーザー |
aaa
|
| 提出日時 | 2018-07-18 11:04:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,362 bytes |
| コンパイル時間 | 832 ms |
| コンパイル使用メモリ | 94,068 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 12:37:42 |
| 合計ジャッジ時間 | 1,548 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
using namespace std;
int main() {
long i, j;
int k;
cin >> k;
if (k == 0) {
cout << 1 << endl;
cout << 0 << endl;
return 0;
}
for (i = 2; i <= 30; i++) {
long num = 0;
for (int h = i - 1; h >= 1; h--) {
num += h;
}
// cout << "num->" << num << endl;
if (num == k) {
cout << i << endl;
for (i; i > 0; i--) {
cout << 1;
if (i - 1 != 0) {
cout << " ";
}
else {
cout << endl;
}
}
getchar();
getchar();
return 0;
}
for (j = 1; j <= 30 - i; j++) {
//long num2 = j*i + i;
long num2 = ( pow(2,j)-1) * num + num;
// cout << "num2->" << num2 << endl;
// cout << "j->" << j << " i->" << i << endl << endl;
if (num2 > k) break;
if (num2 == k) {
cout << j + i << endl;
for (int jj = 0; jj < j; jj++) {
cout << 0 << " ";
}
for (int jj = 0; jj < i; jj++) {
cout << 1;
if (jj + 1 != i) {
cout << " ";
}
else {
cout << endl;
}
}
getchar();
getchar();
return 0;
}
}
}
getchar();
getchar();
return 0;
}
aaa