結果

問題 No.1529 Constant Lcm
ユーザー nasutarou1341nasutarou1341
提出日時 2021-06-04 20:26:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,688 ms / 3,000 ms
コード長 658 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 375,948 KB
最終ジャッジ日時 2023-08-12 09:27:06
合計ジャッジ時間 28,295 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,260 KB
testcase_01 AC 94 ms
76,324 KB
testcase_02 AC 72 ms
71,308 KB
testcase_03 AC 71 ms
71,036 KB
testcase_04 AC 71 ms
71,128 KB
testcase_05 AC 71 ms
71,124 KB
testcase_06 AC 70 ms
71,284 KB
testcase_07 AC 70 ms
71,260 KB
testcase_08 AC 71 ms
71,056 KB
testcase_09 AC 73 ms
71,104 KB
testcase_10 AC 2,170 ms
350,624 KB
testcase_11 AC 742 ms
184,420 KB
testcase_12 AC 123 ms
82,820 KB
testcase_13 AC 2,079 ms
312,540 KB
testcase_14 AC 1,004 ms
226,996 KB
testcase_15 AC 1,105 ms
235,292 KB
testcase_16 AC 809 ms
200,388 KB
testcase_17 AC 479 ms
144,396 KB
testcase_18 AC 524 ms
150,052 KB
testcase_19 AC 1,082 ms
230,696 KB
testcase_20 AC 2,527 ms
375,292 KB
testcase_21 AC 2,593 ms
375,696 KB
testcase_22 AC 2,566 ms
375,408 KB
testcase_23 AC 2,538 ms
375,948 KB
testcase_24 AC 2,688 ms
375,488 KB
testcase_25 AC 2,528 ms
375,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
MOD = 998244353

V = [i for i in range(N)]
L = [{} for i in range(N)]
for i in range(2, N):
  if V[i] != 1:
    t = V[i]
    for j in range(i, N, i):
      V[j] //= t
      if t in L[j]:
        L[j][t] += 1
      else:
        L[j][t] = 1

R = {}
for i in range(1, N // 2 + 1):
  t = N - i
  for k, v in L[i].items():
    if k in L[t]:
      v += L[t][k]
    if k not in R:
      R[k] = v
    else:
      R[k] = max(R[k], v)
  for k, v in L[t].items():
    if k in L[i]:
      v += L[i][k]
    if k not in R:
      R[k] = v
    else:
      R[k] = max(R[k], v)

ans = 1
for k, v in R.items():
  ans *= pow(k, v, MOD)
  ans %= MOD

print(ans)
0