結果

問題 No.2891 Mint
ユーザー Tatsu_mrTatsu_mr
提出日時 2024-09-14 11:10:50
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 913 bytes
コンパイル時間 5,412 ms
コンパイル使用メモリ 309,680 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-14 11:10:58
合計ジャッジ時間 8,099 ms
ジャッジサーバーID
(参考情報)
judge6 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 2 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 2 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 AC 2 ms
5,376 KB
testcase_54 AC 2 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
            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;
}
0