結果
問題 |
No.688 E869120 and Constructing Array 2
|
ユーザー |
|
提出日時 | 2020-11-25 18:41:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 814 bytes |
コンパイル時間 | 1,634 ms |
コンパイル使用メモリ | 169,112 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 19:24:30 |
合計ジャッジ時間 | 2,478 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 WA * 1 |
コンパイルメッセージ
main.cpp: In function 'std::vector<int> zero_one(ll)': main.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type] 25 | } | ^
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> zero_one(ll k){ ll zero = 1; if(k == 0){ vector<int> ret(2); ret.at(0) = 0; ret.at(1) = 0; return ret; } for(int i = 0; i <= 30; i++){ for(int j = 2; i + j <= 30; j++){ ll tmp = j * (j - 1) / 2; if(tmp * zero == k){ vector<int> ret(2); ret.at(0) = i; ret.at(1) = j; return ret; } } zero *= 2; } } int main(void){ ll k; cin >> k; auto ans = zero_one(k); cout << ans.at(0) + ans.at(1) << endl; for(int i = 0; i < ans.at(0); i++) cout << 0 << " "; for(int i = 0; i < ans.at(1); i++) cout << 1 << " "; cout << endl; return 0; }