結果

問題 No.2045 Two Reflections
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-09-08 01:12:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,292 bytes
コンパイル時間 2,097 ms
コンパイル使用メモリ 202,380 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-05-02 21:53:50
合計ジャッジ時間 5,626 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,112 KB
testcase_01 WA -
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll m = 998244353;
ll mpow(ll a, ll n) {
    ll ret = 1;
    while (n) {
        if (n & 1) {
            ret *= a;
            ret %= m;
        }
        n >>= 1;
        a = (a * a) % m;
    }
    return ret;
}
int main () {
    int N, p, q;
    cin >> N >> p >> q;
    int A[100010];
    for (int i = 0; i < N; i ++) {
        A[i] = i;
    }
    reverse(A, A + p);
    reverse(A+(N-q), A+N);
    vector<int> did(N, 0);
    vector<int> ans(N, 0);
    vector<int> lpr(N + 1, 0);
    lpr[0] = lpr[1] = 1;
    for (int i = 2; i <= N; i ++) {
        if (!lpr[i]) {
            lpr[i] = i;
            for (int j = 2; j * i <= N; j ++) {
                lpr[i * j] = i;
            }
        }
    }
    for (int i = 0; i < N; i ++) {
        int cnt = 0;
        int fl = i;
        do {
            cnt ++;
            fl = A[fl];
        } while (fl != i);
        while (cnt > 1) {
            int c = 0;
            int p = lpr[cnt];
            while (cnt % p == 0) {
                c ++;
                cnt /= p;
            }
            ans[p] = max(ans[p], c);
        }
    }
    ll r = 1;
    for (int i = 2; i <= N; i ++) {
        r *= mpow(i, ans[i]);
        r %= m;
    }
    cout << (r * 2) % m << endl;
}
0