結果

問題 No.1529 Constant Lcm
ユーザー charmychachachacharmychachacha
提出日時 2021-06-04 20:23:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 428 ms / 3,000 ms
コード長 938 bytes
コンパイル時間 1,910 ms
コンパイル使用メモリ 178,816 KB
実行使用メモリ 80,632 KB
最終ジャッジ日時 2023-08-12 09:22:28
合計ジャッジ時間 11,886 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 257 ms
80,404 KB
testcase_01 AC 263 ms
80,380 KB
testcase_02 AC 267 ms
80,632 KB
testcase_03 AC 260 ms
80,412 KB
testcase_04 AC 267 ms
80,420 KB
testcase_05 AC 262 ms
80,484 KB
testcase_06 AC 255 ms
80,392 KB
testcase_07 AC 269 ms
80,628 KB
testcase_08 AC 268 ms
80,384 KB
testcase_09 AC 267 ms
80,428 KB
testcase_10 AC 390 ms
80,432 KB
testcase_11 AC 316 ms
80,524 KB
testcase_12 AC 270 ms
80,496 KB
testcase_13 AC 383 ms
80,432 KB
testcase_14 AC 332 ms
80,500 KB
testcase_15 AC 335 ms
80,436 KB
testcase_16 AC 324 ms
80,388 KB
testcase_17 AC 291 ms
80,444 KB
testcase_18 AC 294 ms
80,392 KB
testcase_19 AC 332 ms
80,400 KB
testcase_20 AC 422 ms
80,436 KB
testcase_21 AC 418 ms
80,512 KB
testcase_22 AC 408 ms
80,624 KB
testcase_23 AC 428 ms
80,468 KB
testcase_24 AC 419 ms
80,380 KB
testcase_25 AC 399 ms
80,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N; cin >> N; 
	int S[1000010] = {}; 
	for(int i = 2; i <= 1000000; i++){
		for(int j = 1; i * j <= 1000000; j++){
			if(S[i * j] == 0) S[i * j] = i; 
		}
	} 
	vector<pair<int, int>> A[1000010]; 
	for(int i = 2; i <= 1000000; i++){ 
		int n = 0; int tmp = i; 
		while(tmp % S[i] == 0){
			n ++; tmp /= S[i]; 
		}
		A[i] = A[tmp]; 
		A[i].push_back(make_pair(S[i], n)); 
	}
	int C[1000010] = {}; 
	for(int i = 1; i <= 1000000; i++){
		if(i > N - i) break; 
		map<int, int> mp; 
		for(auto p : A[i]) mp[p.first] += p.second; 
		for(auto p : A[N-i]) mp[p.first] += p.second;
		for(auto p : mp){
			C[p.first] = max(C[p.first], p.second); 
		}
	}
	long long ans = 1; 
	long long mod = 998244353; 
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < C[i]; j++){
			ans *= (long long) i; ans %= mod; 
		}
	}
	cout << ans << "\n";
}
0