結果

問題 No.2045 Two Reflections
ユーザー tomeruntomerun
提出日時 2022-08-19 22:15:03
言語 Crystal
(1.11.2)
結果
WA  
実行時間 -
コード長 409 bytes
コンパイル時間 16,413 ms
コンパイル使用メモリ 298,316 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 00:56:43
合計ジャッジ時間 17,440 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

require "big"
MOD = 998244353i64
n, p, q = read_line.split.map(&.to_i)
a = Array.new(n) { |i| i }
a_orig = a.dup
a[...p] = a[...p].reverse
a[-q..] = a[-q..].reverse
ans = BigInt.new(1)
visited = Array.new(n, false)
n.times do |i|
  next if visited[i]
  cur = i
  len = 0
  while !visited[cur]
    visited[cur] = true
    len += 1
    cur = a[cur]
  end
  ans = ans.lcm(BigInt.new(len))
end
puts ans * 2 % MOD
0