結果

問題 No.2880 Max Sigma Mod
ユーザー HIcoder
提出日時 2024-09-10 22:25:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 3,000 ms
コード長 786 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 115,520 KB
最終ジャッジ日時 2025-02-24 06:34:36
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<numeric>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,int> P;
typedef pair<int,P> PP; 
const ll MOD=998244353;

int main(){
    ll N,M;
    cin>>N>>M;

    vector<ll> plus(N+1,M);
    for(int i=1;i<=N;i++){
        for(int j=i;j<=N;j+=i){
            plus[j]-=i;
        }
    }
    vector<ll> S(N+1);//S[x]= Σ(x mod i) (i=1,2,...,N)
    S[0]=0;
    for(int i=1;i<=N;i++){
        S[i]=S[i-1]+plus[i];
    }

    ll ans=0;
    for(int x=1;x<=N;x++){
        ans=max(ans,S[x]);
    }
    cout<<ans<<endl;

}
0