結果

問題 No.2880 Max Sigma Mod
ユーザー tottoripapertottoripaper
提出日時 2024-09-12 16:36:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 3,000 ms
コード長 1,430 bytes
コンパイル時間 2,411 ms
コンパイル使用メモリ 210,404 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-12 16:36:14
合計ジャッジ時間 4,911 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 52 ms
5,376 KB
testcase_06 AC 43 ms
5,376 KB
testcase_07 AC 32 ms
5,376 KB
testcase_08 AC 27 ms
5,376 KB
testcase_09 AC 17 ms
5,376 KB
testcase_10 AC 25 ms
5,376 KB
testcase_11 AC 36 ms
5,376 KB
testcase_12 AC 16 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 33 ms
5,376 KB
testcase_15 AC 60 ms
5,376 KB
testcase_16 AC 60 ms
5,376 KB
testcase_17 AC 60 ms
5,376 KB
testcase_18 AC 60 ms
5,376 KB
testcase_19 AC 60 ms
5,376 KB
testcase_20 AC 6 ms
5,376 KB
testcase_21 AC 21 ms
5,376 KB
testcase_22 AC 34 ms
5,376 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 23 ms
5,376 KB
testcase_25 AC 51 ms
5,376 KB
testcase_26 AC 52 ms
5,376 KB
testcase_27 AC 53 ms
5,376 KB
testcase_28 AC 58 ms
5,376 KB
testcase_29 AC 28 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 5 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 4 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 5 ms
5,376 KB
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 1 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 4 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using ll = std::int64_t;

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int N, M;
    std::cin >> N >> M;

    int L = std::max(N, M);
    std::vector<int> spf(L + 1, 0), primes;
    for(int i=2;i<=L;i++){
        if(spf[i] == 0){
            spf[i] = i;
            primes.emplace_back(i);
        }

        for(int p : primes){
            if(p > spf[i] || !(i <= L / p)){break;}
            spf[i * p] = p;
        }
    }

    ll res = 0;
    ll now = 0;
    for(int i=1;i<=N;i++){
        std::vector<std::tuple<int, int>> factors;
        {
            int x = i;
            while(x > 1){
                int p = spf[x];
                int t = 0;
                while(x % p == 0){
                    x /= p;
                    t += 1;
                }
                factors.emplace_back(p, t);
            }
        }

        std::vector<int> divisors{1};
        for(auto &[p, t] : factors){
            int l = divisors.size();
            divisors.resize(l * (t + 1));
            for(int i=l;i<l*(t+1);i++){
                divisors[i] = divisors[i - l] * p;
            }
        }

        int count = 0;
        for(int d : divisors){
            if(d <= M){
                now -= d - 1;
                count += 1;
            }
        }
        now += M - count;
        res = std::max(res, now);
    }

    std::cout << res << std::endl;
}
0