結果

問題 No.2081 Make a Test Case of GCD Subset
ユーザー 沙耶花沙耶花
提出日時 2022-09-26 03:41:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,097 bytes
コンパイル時間 4,340 ms
コンパイル使用メモリ 260,080 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 02:40:01
合計ジャッジ時間 9,279 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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