結果
問題 | No.2045 Two Reflections |
ユーザー |
![]() |
提出日時 | 2025-06-12 21:22:05 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,065 bytes |
コンパイル時間 | 351 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 66,560 KB |
最終ジャッジ日時 | 2025-06-12 21:24:30 |
合計ジャッジ時間 | 2,654 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 7 |
ソースコード
import sys import math MOD = 998244353 def main(): N, p, q = map(int, sys.stdin.readline().split()) # Compute f[i] for each i f = [0] * (N + 1) # 1-based indexing for i in range(1, N + 1): if i <= p: j = p + 1 - i if j >= (N - q + 1): f[i] = (2 * N - q + 1) - j else: f[i] = j else: if i >= (N - q + 1): f[i] = (2 * N - q + 1) - i else: f[i] = i visited = [False] * (N + 1) lcm = 1 for i in range(1, N + 1): if not visited[i]: current = i cycle_length = 0 while not visited[current]: visited[current] = True current = f[current] cycle_length += 1 if cycle_length > 0: g = math.gcd(lcm, cycle_length) lcm = (lcm // g) * cycle_length # The answer is 2 * lcm mod MOD answer = (2 * lcm) % MOD print(answer) if __name__ == "__main__": main()