結果
問題 | No.1573 Divisor Function |
ユーザー |
👑 ![]() |
提出日時 | 2021-06-27 14:05:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 1,105 bytes |
コンパイル時間 | 832 ms |
コンパイル使用メモリ | 82,844 KB |
最終ジャッジ日時 | 2025-01-22 14:11:45 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 |
ソースコード
#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;