結果

問題 No.2127 Mod, Sum, Sum, Mod
コンテスト
ユーザー 遭難者
提出日時 2022-10-29 00:57:14
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.90.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 891 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,980 ms
コンパイル使用メモリ 208,232 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-06-28 10:08:02
合計ジャッジ時間 14,464 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 TLE * 1
other -- * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <stack>
#include <numeric>
#include <algorithm>
using namespace std;
using ll = long long;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    mint ans0 = 0, ans1 = 0;
    mint jsum = 0;
    for (int j = 1; j <= m; j++)
    {
        const ll nr = n % j;
        jsum += j - 1;
        ans0 += n / j * jsum;
        ans1 += nr * (nr + 1);
    }
    ans0 += ans1 / 2;
    printf("%d\n", ans0.val());
    return 0;
}
0