結果

問題 No.2806 Cornflake Man
コンテスト
ユーザー srjywrdnprkt
提出日時 2024-10-20 23:08:43
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 117 ms / 2,000 ms
+ 510µs
コード長 682 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,581 ms
コンパイル使用メモリ 222,584 KB
実行使用メモリ 22,400 KB
最終ジャッジ日時 2026-10-17 14:07:00
合計ジャッジ時間 5,285 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0