結果
問題 |
No.2806 Cornflake Man
|
ユーザー |
![]() |
提出日時 | 2024-10-20 23:08:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 296 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 3,394 ms |
コンパイル使用メモリ | 203,244 KB |
最終ジャッジ日時 | 2025-02-24 22:05:38 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, M, A, x; cin >> N >> M >> A; set<int> st, st2; vector<int> v; for (int i=0; i<N-1; i++){ cin >> A; st.insert(A); } st2 = st; while(!st.empty()){ x = *st.begin(); for (int i=x; i<=M; i+=x){ if (!st2.count(i)){ cout << -1 << endl; return 0; } st.erase(i); } v.push_back(x); } cout << v.size() << endl; for (auto x : v) cout << x << " "; cout << endl; return 0; }