結果
| 問題 | No.3689 LCM Sum (Easy Version) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-12 00:31:30 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 2,000 ms |
| + 381µs | |
| コード長 | 582 bytes |
| 記録 | |
| コンパイル時間 | 2,069 ms |
| コンパイル使用メモリ | 331,932 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-09-06 17:31:25 |
| 合計ジャッジ時間 | 3,232 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 998244353;
int main() {
int N, M;
cin >> N >> M;
if(N > M) swap(N, M);
vector<int> lp(N + 1, -1), f(N + 1, 1);
for(int i = 2; i <= N; ++i) {
if(lp[i] == -1) for(int j = i; j <= N; j += i) lp[j] = i;
f[i] = f[i / lp[i]] * (i / lp[i] % lp[i] == 0 ? 1 : 1 - lp[i]);
}
ll ans = 0;
for(ll n = 1; n <= N; ++n) {
const ll x = N / n, y = M / n;
ans = (ans + n * (f[n] + mod) % mod * (x * (x + 1) / 2 % mod) % mod * (y * (y + 1) / 2 % mod) % mod) % mod;
}
cout << ans << "\n";
}