結果

問題 No.1529 Constant Lcm
ユーザー 夜
提出日時 2021-06-04 20:27:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 711 ms / 3,000 ms
コード長 939 bytes
コンパイル時間 810 ms
コンパイル使用メモリ 90,560 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-12 09:31:06
合計ジャッジ時間 8,636 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 616 ms
4,384 KB
testcase_11 AC 173 ms
4,380 KB
testcase_12 AC 5 ms
4,384 KB
testcase_13 AC 504 ms
4,380 KB
testcase_14 AC 271 ms
4,384 KB
testcase_15 AC 293 ms
4,380 KB
testcase_16 AC 212 ms
4,380 KB
testcase_17 AC 93 ms
4,380 KB
testcase_18 AC 101 ms
4,380 KB
testcase_19 AC 279 ms
4,380 KB
testcase_20 AC 707 ms
4,384 KB
testcase_21 AC 707 ms
4,380 KB
testcase_22 AC 706 ms
4,384 KB
testcase_23 AC 711 ms
4,388 KB
testcase_24 AC 709 ms
4,388 KB
testcase_25 AC 707 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
bool bo[1000010] = { false };
long long mod = 998244353;
int main() {
	long long n;
	cin >> n;
	long long ans = 1;
	bo[1] = true;
	for (long long i = 2; i < n; i++) {
		for (long long j = 2; j * j <= i; j++) {
			if (i % j == 0) {
				bo[i] = true;
				break;
			}
		}
	}
	for (long long i = 2; i < n; i++){
		long long m = 0;
		if (!bo[i]) {
			long long co = 0;
			for (long long j = i; j < n; j *= i) {
				co++;
				long long co1 = 0;
				long long k = n - j;
				while (k % i == 0) {
					k /= i;
					co1++;
				}
				m = max(m, co + co1);
			}
		}
		for (long long j = 0; j < m; j++) {
			ans *= i;
			ans %= mod;
		}
	}
	cout << ans << endl;
}
0