結果
問題 |
No.2081 Make a Test Case of GCD Subset
|
ユーザー |
![]() |
提出日時 | 2022-09-26 03:42:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,102 bytes |
コンパイル時間 | 4,234 ms |
コンパイル使用メモリ | 251,524 KB |
最終ジャッジ日時 | 2025-02-07 15:55:25 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 |
ソースコード
#include <stdio.h> #include <atcoder/all> #include <bits/stdc++.h> using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 bool F[100001]; int main(){ vector<int> ps; for(int i=2;i<=100000;i++){ if(F[i]==true)continue; ps.push_back(i); for(int j=i;j<=100000;j+=i)F[j] = true; } int l = 0,r = ps.size()-1; int M; cin>>M; vector<int> ans(1,1); while(M!=0){ if(M<=r-l+1){ rep(j,M){ ans.push_back(ps[l]); l++; } break; } int t = 1; int cnt = 0; while(t*2-1<=M){ t*=2; cnt++; } M -= t - 1; int P = ps[l]; int Cur = 1; rep(j,cnt){ if(Cur * P <= 100000){ Cur *= P; ans.push_back(Cur); continue; } while(P*ps[r]>100000)r--; ans.push_back(P*ps[r]); int tt = P*ps[r]; while(j!=cnt-1 && tt*P<=100000){ tt *= P; ans.push_back(tt); j++; } r--; } l++; } cout<<ans.size()<<endl; rep(i,ans.size()){ if(i!=0)cout<<' '; cout<<ans[i]; } cout<<endl; return 0; }