結果
| 問題 |
No.2891 Mint
|
| コンテスト | |
| ユーザー |
Tatsu_mr
|
| 提出日時 | 2024-09-14 11:14:26 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 197 ms / 2,000 ms |
| コード長 | 931 bytes |
| コンパイル時間 | 5,611 ms |
| コンパイル使用メモリ | 308,312 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 11:14:37 |
| 合計ジャッジ時間 | 10,150 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 |
ソースコード
#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;
mint res = (mint(fst) + mint(lst)) * mint(cnt) / mint(2);
return 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);
break;
} 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;
}
Tatsu_mr