結果

問題 No.1573 Divisor Function
ユーザー 👑 NachiaNachia
提出日時 2021-06-27 14:05:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,105 bytes
コンパイル時間 1,042 ms
コンパイル使用メモリ 84,392 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-07 17:44:07
合計ジャッジ時間 3,878 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,380 KB
testcase_01 AC 9 ms
4,380 KB
testcase_02 AC 37 ms
4,380 KB
testcase_03 AC 8 ms
4,380 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 4 ms
4,384 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 28 ms
4,380 KB
testcase_09 AC 11 ms
4,380 KB
testcase_10 AC 28 ms
4,384 KB
testcase_11 AC 10 ms
4,380 KB
testcase_12 AC 6 ms
4,384 KB
testcase_13 AC 28 ms
4,380 KB
testcase_14 AC 27 ms
4,384 KB
testcase_15 AC 28 ms
4,380 KB
testcase_16 AC 28 ms
4,384 KB
testcase_17 AC 15 ms
4,380 KB
testcase_18 AC 35 ms
4,380 KB
testcase_19 AC 37 ms
4,384 KB
testcase_20 AC 32 ms
4,384 KB
testcase_21 AC 36 ms
4,380 KB
testcase_22 AC 35 ms
4,380 KB
testcase_23 AC 32 ms
4,384 KB
testcase_24 AC 35 ms
4,380 KB
testcase_25 AC 37 ms
4,380 KB
testcase_26 AC 36 ms
4,384 KB
testcase_27 AC 33 ms
4,384 KB
testcase_28 AC 31 ms
4,380 KB
testcase_29 AC 35 ms
4,384 KB
testcase_30 AC 35 ms
4,384 KB
testcase_31 AC 32 ms
4,384 KB
testcase_32 AC 35 ms
4,380 KB
testcase_33 AC 36 ms
4,380 KB
testcase_34 AC 30 ms
4,384 KB
testcase_35 AC 31 ms
4,384 KB
testcase_36 AC 29 ms
4,380 KB
testcase_37 AC 35 ms
4,388 KB
testcase_38 AC 37 ms
4,380 KB
testcase_39 AC 37 ms
4,380 KB
testcase_40 AC 37 ms
4,380 KB
testcase_41 AC 37 ms
4,384 KB
testcase_42 AC 37 ms
4,380 KB
testcase_43 AC 37 ms
4,380 KB
testcase_44 AC 37 ms
4,380 KB
testcase_45 AC 37 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

using mll = atcoder::static_modint<998244353>;

int main(){
  ll n,m; cin >> n >> m;
  vector<ll> turn;
  turn.push_back(0);
  turn.push_back(m);
  for(ll k=1; k<=50000; k++) turn.push_back(k);
  for(ll k=1; k<=50000; k++) turn.push_back(n/k);
  sort(turn.begin(),turn.end());
  
  mll ans = 0;

  for(int i=1; i<turn.size(); i++){
    ll rk = turn[i];
    ll lk = turn[i-1];
    if(rk == lk) continue;
    if(rk > m) continue;
    ll maxi = n/rk;
    if(maxi == 0) continue;
    //cout << "k = (" << lk << "," << rk << "]" << endl;
    //cout << "maxi = " << maxi << endl;
    mll sumk = mll(rk)*(rk+1)/2 - mll(lk)*(lk+1)/2;
    //cout << "sumk = " << sumk.val() << endl;
    ans += sumk * (mll(maxi+2) * (maxi+1) / 2 - 1);
  }

  cout << ans.val() << "\n";
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0