結果
問題 |
No.689 E869120 and Constructing Array 3
|
ユーザー |
|
提出日時 | 2019-02-15 13:09:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 677 bytes |
コンパイル時間 | 802 ms |
コンパイル使用メモリ | 71,472 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 10:24:34 |
合計ジャッジ時間 | 2,054 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include<iostream> #include<vector> using namespace std; int main(){ int n; cin >> n; vector<int> ans; if(n == 0){ cout << "2\n2 2\n"; return 0; } int two = 0, three = 0; for(int i = 1; i < 250; i++){ for(int j = 1; i*j <= n; j++){ if(i + j + n-i*j + 1 <= 250){ two = i, three = j; } } } for(int i = 0; i < two; i++) ans.push_back(2); for(int i = 0; i < three; i++) ans.push_back(3); if(n-(two*three)) ans.push_back(7); for(int i = 0; i < n-(two*three); i++) ans.push_back(12); int len = ans.size(); cout << len << endl; for(int i = 0; i < len; i++){ cout << ans[i] << " \n"[i==len-1]; } return 0; }