結果

問題 No.1529 Constant Lcm
ユーザー ぷらぷら
提出日時 2021-06-04 20:23:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 3,000 ms
コード長 903 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 199,684 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-12 09:21:55
合計ジャッジ時間 3,841 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,380 KB
testcase_01 AC 7 ms
4,380 KB
testcase_02 AC 7 ms
4,380 KB
testcase_03 AC 7 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 7 ms
4,380 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 7 ms
4,376 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 53 ms
4,388 KB
testcase_11 AC 25 ms
4,380 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 45 ms
4,380 KB
testcase_14 AC 34 ms
4,380 KB
testcase_15 AC 34 ms
4,380 KB
testcase_16 AC 25 ms
4,380 KB
testcase_17 AC 18 ms
4,380 KB
testcase_18 AC 19 ms
4,380 KB
testcase_19 AC 34 ms
4,380 KB
testcase_20 AC 51 ms
4,376 KB
testcase_21 AC 51 ms
4,380 KB
testcase_22 AC 53 ms
4,376 KB
testcase_23 AC 51 ms
4,380 KB
testcase_24 AC 53 ms
4,380 KB
testcase_25 AC 58 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int N;
    cin >> N;
    vector<bool>prime(1000001,true);
    for(int i = 2; i <= 1000000; i++) {
        if(prime[i]) {
            for(int j = 2*i; j <= 1000000; j += i) {
                prime[j] = false;
            }
        }
    }
    long long tmp = 1;
    constexpr int mod = 998244353;
    for(int i = 2; i < N; i++) {
        if(!prime[i]) {
            continue;
        }
        long long mx = 0;
        for(int j = i; j < N; j += i) {
            int x = j;
            long long y = 1;
            while (x%i == 0) {
                x /= i;
                y *= i;
            }
            x = N-j;
            while (x%i == 0) {
                x /= i;
                y *= i;
            }
            mx = max(mx,y);
        }
        mx %= mod;
        tmp *= mx;
        tmp %= mod;
    }
    cout << tmp << endl;
}
0