結果
| 問題 | No.3686 Coprime Sum |
| コンテスト | |
| ユーザー |
KEYBO
|
| 提出日時 | 2026-09-06 22:50:15 |
| 言語 | C++23(gnu拡張gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,203 bytes |
| 記録 | |
| コンパイル時間 | 5,997 ms |
| コンパイル使用メモリ | 386,668 KB |
| 実行使用メモリ | 43,648 KB |
| 最終ジャッジ日時 | 2026-09-06 22:50:31 |
| 合計ジャッジ時間 | 9,299 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvc = vector<vc>;
using vvb = vector<vb>;
using vvl = vector<vl>;
using mint = modint998244353;
using vm = vector<mint>;
void sieve(ll N, vb &del) {
for (ll p = 2; p*p <= N; p++) {
if (del[p]) continue;
for (ll a = p*p; a <= N; a += p) {
del[a] = true;
}
}
return;
}
int main() {
ll N,M;
cin >> N >> M;
ll mod = 998244353;
vb del(N + 1, false);
sieve(N, del);
vi mu(N + 1, 1);
for (ll a = 2; a <= N; a++) {
if (del[a]) continue;
for (ll b = 1; a*b <= N; b++) {
if (b%a == 0) mu[a*b] = 0;
else mu[a*b] *= -1;
}
}
ll ans = 0;
for (ll d = 1; d <= min(N, M); d++) {
ll n = N/d,m = M/d;
n = ((n + 1)*n/2)%mod,m = ((m + 1)*m/2)%mod;
n = (n*d)%mod,m = (m*d)%mod;
ll now = mu[d];
now = (now*n)%mod;
now = (now*m)%mod;
ans += now;
ans %= mod;
}
cout << ans << endl;
return 0;
}
KEYBO