結果

問題 No.2940 Sigma Sigma Div Floor Problem
ユーザー ooaiu
提出日時 2024-10-29 17:39:22
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 44 ms / 6,000 ms
コード長 786 bytes
コンパイル時間 2,987 ms
コンパイル使用メモリ 249,632 KB
実行使用メモリ 17,248 KB
最終ジャッジ日時 2024-10-29 17:39:27
合計ジャッジ時間 5,037 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) (void(0))
#endif

#include <atcoder/modint>
using mint = atcoder::modint998244353;

void solve() {
    int N;
    cin >> N;
    assert( N <= (int)2e6);
    vector<int> D(N + 1);
    for(int i = 1; i <= N; i++) {
        for(int j = i; j <= N; j += i) {
            D[j] += 1;
        }
    }
    vector<long long> S(N + 1);
    S[1] = 1; S[2] = 3;
    for(int i = 3; i <= N; i++) S[i] = D[i] + S[i - 1];
    mint ans = 0;
    for(int i = 1; i <= N; i++) {
        ans += S[i];
    }
    cout << ans.val() << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int tt = 1;
    // std::cin >> tt;
    while(tt--) {
        solve();
    }
}
0