結果

問題 No.2609 Decreasing GCDs
ユーザー shobonvipshobonvip
提出日時 2024-01-25 00:56:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 1,000 ms
コード長 1,592 bytes
コンパイル時間 4,406 ms
コンパイル使用メモリ 262,956 KB
実行使用メモリ 9,136 KB
最終ジャッジ日時 2024-01-25 00:57:07
合計ジャッジ時間 9,278 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
9,136 KB
testcase_01 AC 133 ms
9,136 KB
testcase_02 AC 134 ms
9,136 KB
testcase_03 AC 150 ms
9,136 KB
testcase_04 AC 132 ms
9,136 KB
testcase_05 AC 136 ms
9,136 KB
testcase_06 AC 136 ms
9,136 KB
testcase_07 AC 141 ms
9,136 KB
testcase_08 AC 136 ms
9,136 KB
testcase_09 AC 134 ms
9,136 KB
testcase_10 AC 134 ms
9,136 KB
testcase_11 AC 133 ms
9,136 KB
testcase_12 AC 135 ms
9,136 KB
testcase_13 AC 134 ms
9,136 KB
testcase_14 AC 133 ms
9,136 KB
testcase_15 AC 134 ms
9,136 KB
testcase_16 AC 134 ms
9,136 KB
testcase_17 AC 134 ms
9,136 KB
testcase_18 AC 135 ms
9,136 KB
testcase_19 AC 143 ms
9,136 KB
testcase_20 AC 134 ms
9,136 KB
testcase_21 AC 133 ms
9,136 KB
testcase_22 AC 132 ms
9,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	int n; cin >> n;
	int mx = 12345678;
	vector<bool> pl(mx+1);
	vector<int> p;
	for (int i=2; i<=mx; i++){
		if (pl[i]) continue;
		pl[i] = 1;
		p.push_back(i);
		for (int j=i; j<=mx; j+=i){
			pl[j] = 1;
		}		
	}

	vector<int> ans;
	rep(i,0,n){
		ans.push_back(p[i] * p[i+1]);
	}
	reverse(ans.begin(), ans.end());

	int tar = n + 2;
	int piv = 1;
	while (piv < n){
		if (ans[piv] * p[tar] > ans[piv-1]){
			ans[piv] *= p[tar];
			piv++;
		}
		tar++;
	}

	rep(i,0,n){
		cout << ans[i];
		if (i == n-1) cout << '\n';
		else cout << ' ';
	}
}


0