結果
問題 |
No.2880 Max Sigma Mod
|
ユーザー |
|
提出日時 | 2025-09-03 16:10:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 270 ms / 3,000 ms |
コード長 | 732 bytes |
コンパイル時間 | 3,276 ms |
コンパイル使用メモリ | 281,456 KB |
実行使用メモリ | 27,736 KB |
最終ジャッジ日時 | 2025-09-03 16:10:17 |
合計ジャッジ時間 | 8,332 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 48 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; cin >> n >> m; vector<ll> ans(n + 1), dp(n + 1); for (int i = 1; i <= n; i++) ans[i] = ans[i - 1] + m; vector<vector<int>> divs(n + 1); for (int x = 1; x <= n; x++) { for (int y = x; y <= n; y += x) { divs[y].push_back(x); } } for (ll x = 1; x <= n; x++) { dp[x] += dp[x - 1]; for (int y : divs[x]) { dp[x] -= (x - 1) / y * y; dp[x] += x / y * y; } } ll ANS = 0; for (int i = 1; i <= n; i++) ANS = max(ANS, ans[i] - dp[i]); cout << ANS << "\n"; }