結果

問題 No.1396 Giri
ユーザー Example0911Example0911
提出日時 2021-02-14 21:42:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,540 bytes
コンパイル時間 1,985 ms
コンパイル使用メモリ 206,876 KB
実行使用メモリ 7,920 KB
最終ジャッジ日時 2023-09-29 14:59:45
合計ジャッジ時間 3,336 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
7,624 KB
testcase_01 AC 12 ms
7,676 KB
testcase_02 AC 13 ms
7,756 KB
testcase_03 AC 13 ms
7,612 KB
testcase_04 AC 12 ms
7,760 KB
testcase_05 AC 14 ms
7,612 KB
testcase_06 AC 12 ms
7,828 KB
testcase_07 AC 12 ms
7,920 KB
testcase_08 AC 12 ms
7,716 KB
testcase_09 AC 11 ms
7,716 KB
testcase_10 AC 12 ms
7,676 KB
testcase_11 AC 12 ms
7,720 KB
testcase_12 AC 12 ms
7,748 KB
testcase_13 AC 12 ms
7,720 KB
testcase_14 AC 12 ms
7,668 KB
testcase_15 AC 11 ms
7,756 KB
testcase_16 AC 11 ms
7,764 KB
testcase_17 AC 11 ms
7,724 KB
testcase_18 AC 12 ms
7,756 KB
testcase_19 AC 12 ms
7,756 KB
testcase_20 AC 13 ms
7,608 KB
testcase_21 AC 13 ms
7,612 KB
testcase_22 AC 13 ms
7,676 KB
testcase_23 AC 13 ms
7,700 KB
testcase_24 AC 13 ms
7,612 KB
testcase_25 AC 13 ms
7,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 998244353;
bool prime(ll n) {
	if (n == 1)return true;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
struct Sieve {
	int n;
	vector<int> f, primes;
	// n以下の素数を列挙する
	Sieve(int n = 1) :n(n), f(n + 1) {
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; ++i) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i * i; j <= n; j += i) {
				if (!f[j]) f[j] = i;
			}
		}
	}
	// xが素数かどうか判定する
	bool isPrime(int x) { return f[x] == x; }
	// 素因数を全列挙
	vector<int> factorList(int x) {
		vector<int> res;
		while (x != 1) {
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	// ランレングス圧縮
	vector<P> factor(int x) {
		vector<int> fl = factorList(x);
		if (fl.size() == 0) return {};
		vector<P> res(1, P(fl[0], 0));
		for (int p : fl) {
			if (res.back().first == p) {
				res.back().second++;
			}
			else {
				res.emplace_back(p, 1);
			}
		}
		return res;
	}
};
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N; cin >> N;
	map<ll, ll>mp;
	ll tmp = 0;
	for (int i = N; ; i--) {
		if (prime(i)) {
			tmp = i; break;
		}
	}
	Sieve s(1000010);
	vector<int> now = s.primes;
	ll tmp2 = N;
	ll ans = 1;
	for (auto x : now) {
		if (x == tmp)continue;
		N = tmp2;
		N /= x;
		while (N != 0) {
			ans *= x;
			ans %= mod;
			N /= x;
		}
	}
	cout << ans << endl;
	return 0;
}
0