結果

問題 No.2806 Cornflake Man
ユーザー a1048576
提出日時 2024-07-12 21:36:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 343 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 1,720 ms
コンパイル使用メモリ 178,636 KB
実行使用メモリ 25,224 KB
最終ジャッジ日時 2024-07-17 20:26:06
合計ジャッジ時間 4,826 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int n,m;
	cin >> n >> m;
	set<int> s;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i], s.insert(a[i]);
	sort(a.begin(),a.end());
	set<int> v;
	int ans = 0;
	vector<int> an;
	for(int i = 1; i < n; i++) {
		if(v.count(a[i])) continue;
		for(int j = a[i]; j <= m; j+=a[i]) {
			if(!s.count(j)) {
				cout << -1 << endl;
				return 0;
			}
			v.insert(j);
		}
		ans++;
		an.push_back(a[i]);
	}
	cout << ans << endl;
	for(int i = 0; i < ans; i++) cout << an[i] << ' ';
	cout << endl;
}
0