結果
| 問題 |
No.3377 Sigma Index × A Problems
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2025-10-16 00:03:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 2,550 ms / 3,000 ms |
| コード長 | 610 bytes |
| コンパイル時間 | 275 ms |
| コンパイル使用メモリ | 82,096 KB |
| 実行使用メモリ | 79,292 KB |
| 最終ジャッジ日時 | 2025-11-21 20:50:52 |
| 合計ジャッジ時間 | 14,312 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
import math
MOD = 998244353
# Index * A Problem の答えの上界
LIMIT = 42
LCM = [0] + [math.lcm(*range(1, i + 1)) for i in range(1, LIMIT + 2)]
inv_2 = pow(2, MOD - 2, MOD)
def solve():
N = int(input())
def count(ans):
loop = N // LCM[ans]
res = (LCM[ans] // ans) * ((N + 1) * loop - loop * (loop + 1) * inv_2 * LCM[ans]) % MOD
return res
answer = 0
for i in range(1, LIMIT + 1):
answer += (count(i) - count(i + 1)) * i
answer %= MOD
print(answer)
if __name__ == "__main__":
T = int(input())
for _ in range(T):
solve()