結果

問題 No.2045 Two Reflections
ユーザー chineristACchineristAC
提出日時 2022-08-19 23:00:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 1,386 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 75,648 KB
最終ジャッジ日時 2024-04-17 01:38:18
合計ジャッジ時間 3,581 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
65,152 KB
testcase_01 AC 68 ms
65,280 KB
testcase_02 AC 83 ms
71,424 KB
testcase_03 AC 88 ms
71,552 KB
testcase_04 AC 92 ms
75,648 KB
testcase_05 AC 84 ms
71,040 KB
testcase_06 AC 80 ms
70,144 KB
testcase_07 AC 88 ms
74,496 KB
testcase_08 AC 93 ms
74,880 KB
testcase_09 AC 87 ms
72,832 KB
testcase_10 AC 86 ms
73,088 KB
testcase_11 AC 84 ms
71,680 KB
testcase_12 AC 66 ms
65,280 KB
testcase_13 AC 67 ms
65,280 KB
testcase_14 AC 68 ms
65,152 KB
testcase_15 AC 68 ms
65,408 KB
testcase_16 AC 69 ms
65,152 KB
testcase_17 AC 68 ms
65,280 KB
testcase_18 AC 87 ms
71,168 KB
testcase_19 AC 86 ms
71,168 KB
testcase_20 AC 82 ms
71,040 KB
testcase_21 AC 85 ms
71,424 KB
testcase_22 AC 85 ms
71,296 KB
testcase_23 AC 84 ms
71,680 KB
testcase_24 AC 84 ms
71,424 KB
testcase_25 AC 84 ms
71,424 KB
testcase_26 AC 83 ms
71,296 KB
testcase_27 AC 84 ms
71,424 KB
testcase_28 AC 83 ms
71,296 KB
testcase_29 AC 83 ms
71,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush
from itertools import cycle, permutations
from math import log,gcd

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

spf = [i for i in range(10**5+1)]
for p in range(2,10**5+1):
    if spf[p]==p:
        for n in range(p,10**5+1,p):
            spf[n] = p


def peri(N,P):
    LCM = [0] * (N+1)
    visit = [False] * N
    for i in range(N):
        if visit[i]:
            continue
        n = 1
        pos = P[i]
        visit[i] = True
        while pos!=i:
            visit[pos] = True
            n += 1
            pos = P[pos]

        tmp = n
        while tmp!=1:
            p = spf[tmp]
            k = 0
            while tmp%p==0:
                k += 1
                tmp //= p
            LCM[p] = max(LCM[p],k)

    res = 1
    for p in range(2,N+1):
        if spf[p]==p:
            res *= pow(p,LCM[p],998244353)
            res %= 998244353
    return res


mod = 998244353

N,p,q = mi()

if p==1 and q==1:
    exit(print(1))
if p==1:
    p,q = q,p


P = [i for i in range(N)]
for i in range(p//2):
    P[i],P[p-1-i] = P[p-1-i],P[i]

if q==1:
    exit(print(peri(N,P)))

for i in range(q//2):
    P[-i-1],P[-(q-1-i)-1] = P[-(q-1-i)-1],P[-i-1]



print((peri(N,P)*2) % 998244353)





0