結果
| 問題 |
No.3377 Sigma Index × A Problems
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2025-10-18 11:50:28 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,388 ms / 3,000 ms |
| コード長 | 837 bytes |
| コンパイル時間 | 2,760 ms |
| コンパイル使用メモリ | 280,948 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-11-21 20:51:06 |
| 合計ジャッジ時間 | 13,182 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using ull = unsigned long long;
using mint = atcoder::modint998244353;
constexpr int LIMIT = 42; // Index * A Problem の解の上限
vector<ull> LCM; // 1, 2, ..., i の総LCM
void init() {
LCM = vector<ull>(LIMIT + 1);
LCM[1] = 1;
for (int i = 2; i <= LIMIT; i++) {
LCM[i] = lcm(LCM[i - 1], i);
}
}
void solve() {
ull N;
cin >> N;
auto count = [&](int ans) {
mint loop = mint(N / LCM[ans]);
return (mint(LCM[ans]) / ans) * (mint(N + 1) * loop - loop * (loop + 1) * mint(LCM[ans]) / 2);
};
mint answer = 0;
for (int i = 1; i <= LIMIT; i++) {
answer += count(i);
}
cout << answer.val() << "\n";
}
int main() {
init();
int T;
cin >> T;
while (T--) solve();
}