結果
| 問題 | No.2081 Make a Test Case of GCD Subset |
| コンテスト | |
| ユーザー |
houren
|
| 提出日時 | 2022-09-25 22:04:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,172 bytes |
| 記録 | |
| コンパイル時間 | 1,839 ms |
| コンパイル使用メモリ | 175,596 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-22 14:38:31 |
| 合計ジャッジ時間 | 5,436 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int m;
cin >> m;
if(m==0){
cout << "1\n1\n";
return 0;
}
vector<bool> b(100001,true);
vector<int> ans, pn;
for(int i=2;i<=100000;i++){
if(b[i]){
pn.push_back(i);
for(int j=2;i*j<=100000;j++) b[i*j] = false;
}
}
int cnt = 30, now = 0, n = pn.size()-1, x = n;
while(cnt>=0){
if(m&(1<<cnt)){
ans.push_back(pn[n--]);
while(pn[now]*pn[x]>100000) x--;
rep(i,cnt) ans.push_back(pn[now]*pn[x--]);
}
now++;
cnt--;
}
sort(all(ans));
cout << ans.size() << '\n';
for(int x:ans) cout << x << ' ';
cout << '\n';
return 0;
}
houren