結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー | 🍮かんプリン |
提出日時 | 2019-03-07 11:26:37 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 885 bytes |
コンパイル時間 | 376 ms |
コンパイル使用メモリ | 52,300 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-05 19:22:15 |
合計ジャッジ時間 | 1,334 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,376 KB |
ソースコード
#include <iostream> using namespace std; int main(){ int K,c_0,c_1; cin >> K; for(c_0 = 0; c_0 == 0 || K % (1 << (c_0 - 1)) == 0; c_0++) { if (c_0 == 0) { for(c_1 = 0; c_1 * (c_1 - 1) < K * 2; c_1++) {} if (c_1 * (c_1 - 1) == K * 2) { break; } } else { for (c_1 = 0; c_1 * (c_1 - 1) < K / (1 << (c_0 - 1)); c_1++) {} if (c_1 * (c_1 - 1) == K / (1 << (c_0 - 1))) { if (c_0 + c_1 <= 30) break; } } } cout << (c_0 + c_1 == 0 ? 1 : c_0 + c_1) << endl; if (c_0 + c_1 == 0) { cout << 0; } else { for(int i = 0; i < c_0; i++) { cout << 0 << " "; } for(int i = 0; i < c_1; i++) { cout << 1 << " "; } } cout << endl; return 0; }