結果

問題 No.2081 Make a Test Case of GCD Subset
ユーザー kwm_tkwm_t
提出日時 2022-09-27 19:27:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,763 bytes
コンパイル時間 4,159 ms
コンパイル使用メモリ 264,228 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-24 04:01:08
合計ジャッジ時間 8,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 3 ms
4,380 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
using mint = modint998244353;
const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
vector<int> sieve() {
	vector<int>is_prime(100001), ret;
	is_prime[0] = false;
	is_prime[1] = false;
	for (int i = 2; i <= 100000; ++i) {//初期化
		is_prime[i] = true;
	}

	for (int i = 2; i <= 100000; ++i) {
		if (is_prime[i]) {
			ret.push_back(i);
			for (int j = 2 * i; j <= 100000; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int m; cin >> m;
	if (0 == m) {
		cout << 1 << endl;
		cout << 1 << endl;
		return 0;
	}
	auto p = sieve();
	reverse(all(p));
	vector<int>ans;
	rep(i, 30) {
		if (1 & (m >> i)) {
			rep(j, i) {
				ans.push_back(p.back());
			}
			if (0 != i)p.pop_back();
			ans.push_back(p.back());
			p.pop_back();
		}
	}
	set<int>st;
	rep(i, ans.size()) {
		if (st.count(ans[i])) {
			ans[i] *= p.back();
			p.pop_back();
		}
		st.insert(ans[i]);
	}
	cout << ans.size() << endl;
	rep(i, ans.size())cout << ans[i] << " ";
	return 0;
}
0