結果
問題 |
No.2891 Mint
|
ユーザー |
![]() |
提出日時 | 2024-09-14 11:09:36 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 894 bytes |
コンパイル時間 | 5,822 ms |
コンパイル使用メモリ | 307,764 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 11:09:44 |
合計ジャッジ時間 | 8,329 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 WA * 22 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using lint = long long; using mint = atcoder::modint998244353; int main() { lint n, m; cin >> n >> m; lint sq = sqrtl(m); mint ans = 0; for (lint i = 1; i <= min(sq, n); i++) { ans += mint(m % i); } auto calc = [](lint fst, lint lst, lint q) -> mint { lint cnt = (fst - lst) / q + 1; lint res = (fst + lst) * cnt / 2; return mint(res); }; for (lint q = m / (sq + 1); q >= 1 && n > sq; q--) { if (q == m / n) { lint fst = m % (m / (q + 1) + 1); lint lst = m % n; ans += calc(fst, lst, q); } else { lint fst = m % (m / (q + 1) + 1); lint lst = m % q; ans += calc(fst, lst, q); } } ans += mint(max(0LL, n - m)) * mint(m); cout << ans.val() << endl; }