結果

問題 No.2081 Make a Test Case of GCD Subset
ユーザー hourenhouren
提出日時 2022-09-25 22:04:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,172 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 172,944 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 02:13:54
合計ジャッジ時間 6,258 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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