結果

問題 No.2880 Max Sigma Mod
ユーザー HIcoder
提出日時 2024-09-29 11:17:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 3,000 ms
コード長 767 bytes
コンパイル時間 1,305 ms
コンパイル使用メモリ 114,988 KB
最終ジャッジ日時 2025-02-24 14:07:18
ジャッジサーバーID
(参考情報)
judge3 / 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> cand(N+1,0);

   
    vector<ll> minus(N+1,0);
    for(int x=1;x<=N;x++){
        for(int y=x;y<=N;y+=x){
            minus[y]-=x;
        }
    }
    ll ans=0;
    for(int x=1;x<=N;x++){
        cand[x]+=M;
        cand[x]+=minus[x];
        cand[x]+=cand[x-1];
        ans=max(ans,cand[x]);
    }

    cout<<ans<<endl;
}
0