結果

問題 No.1529 Constant Lcm
ユーザー ぷらぷら
提出日時 2021-06-04 20:19:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 858 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 201,960 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 23:35:38
合計ジャッジ時間 3,560 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
        }
        int mx = 0;
        for(int j = 1; i*j < N; j++) {
            int x = i*j,y = 1;
            while (x%i == 0) {
                x /= i;
                y *= i;
            }
            x = N-i*j;
            while (x%i == 0) {
                x /= i;
                y *= i;
            }
            mx = max(mx,y);
        }
        tmp *= mx;
        tmp %= mod;
    }
    cout << tmp << endl;
}
0