結果

問題 No.2880 Max Sigma Mod
コンテスト
ユーザー t98slider
提出日時 2024-09-08 13:00:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 440 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 192,992 KB
最終ジャッジ日時 2025-02-24 05:27:05
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 WA * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from main.cpp:1:
In function ‘constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]’,
    inlined from ‘int main()’ at main.cpp:16:16:
/usr/include/c++/13/bits/stl_algobase.h:262:7: warning: ‘l’ is used uninitialized [-Wuninitialized]
  262 |       if (__a < __b)
      |       ^~
main.cpp: In function ‘int main()’:
main.cpp:16:9: note: ‘l’ was declared here
   16 |     int l = max(l, m - 50);
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    auto f = [&](int x){
        ll res = 0;
        for(int i = 2; i <= m; i++) res += x % i;
        return res;
    };
    ll ans = f(n);
    int l = max(l, m - 50);
    int r = min(n, m + 50);
    for(int i = l; i <= r; i++) ans = max(ans, f(i));
    cout << ans << '\n';
}
0