結果
| 問題 | No.3688 LCM Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-28 01:06:33 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 687 bytes |
| 記録 | |
| コンパイル時間 | 1,977 ms |
| コンパイル使用メモリ | 332,224 KB |
| 実行使用メモリ | 354,816 KB |
| 最終ジャッジ日時 | 2026-09-06 17:32:10 |
| 合計ジャッジ時間 | 22,818 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | AC * 10 TLE * 1 |
ソースコード
#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), mu(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;
mu[i] = (i % (lp[i] * lp[i]) == 0 ? 0 : mu[i / lp[i]] * -1);
}
vector<int> f(N + 1, 0);
for(int i = 1; i <= N; ++i) for(int j = i; j <= N; j += i) f[j] += i * mu[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";
}