結果

問題 No.2045 Two Reflections
ユーザー chineristAC
提出日時 2022-08-19 22:53:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,149 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 81,968 KB
実行使用メモリ 76,020 KB
最終ジャッジ日時 2024-10-08 10:08:53
合計ジャッジ時間 3,358 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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


mod = 998244353

N,p,q = mi()

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]


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

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

print((res*2) % 998244353)





0