結果

問題 No.1737 One to N
ユーザー ぷらぷら
提出日時 2021-11-12 21:32:34
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 1,138 bytes
コンパイル時間 2,043 ms
コンパイル使用メモリ 207,780 KB
実行使用メモリ 7,236 KB
最終ジャッジ日時 2023-08-16 21:44:40
合計ジャッジ時間 3,613 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,236 KB
testcase_01 AC 9 ms
7,000 KB
testcase_02 AC 9 ms
6,936 KB
testcase_03 AC 8 ms
6,996 KB
testcase_04 AC 8 ms
6,884 KB
testcase_05 AC 8 ms
6,880 KB
testcase_06 AC 9 ms
6,996 KB
testcase_07 AC 8 ms
6,884 KB
testcase_08 AC 8 ms
7,208 KB
testcase_09 AC 8 ms
6,932 KB
testcase_10 AC 8 ms
6,940 KB
testcase_11 AC 8 ms
6,944 KB
testcase_12 AC 8 ms
6,888 KB
testcase_13 AC 9 ms
6,984 KB
testcase_14 AC 9 ms
7,060 KB
testcase_15 AC 8 ms
6,880 KB
testcase_16 AC 9 ms
6,936 KB
testcase_17 AC 8 ms
6,932 KB
testcase_18 AC 9 ms
7,064 KB
testcase_19 AC 8 ms
7,004 KB
testcase_20 AC 8 ms
6,876 KB
testcase_21 AC 8 ms
7,000 KB
testcase_22 AC 8 ms
6,888 KB
testcase_23 AC 8 ms
6,936 KB
testcase_24 AC 9 ms
7,064 KB
testcase_25 AC 8 ms
6,944 KB
testcase_26 AC 8 ms
6,984 KB
testcase_27 AC 9 ms
6,932 KB
testcase_28 AC 8 ms
6,932 KB
testcase_29 AC 8 ms
7,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct primenumber {
    vector<int> spf;
    primenumber(int N) {
        init(N);
    }
    void init(int N) {
        spf.assign(N+1,0);
        for(int i = 0; i <= N; i++) {
            spf[i] = i;
        }
        for(int i = 2; i*i <= N; i++) {
            if(spf[i] == i) {
                for(int j = i*i; j <= N; j += i) {
                    if(spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    bool is_prime(long long n) {
        bool flag = true;
        if(n == 1) {
            flag = false;
        }
        for(long long i = 2; i*i <= n; i++) {
            if(n%i == 0) {
                flag = false;
            }
        }
        return flag;
    }
    map<int,int> get(int n) {
        map<int,int> m;
        while(n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};

int main() {
    int N;
    cin >> N;
    primenumber zz(1000000);
    int ans = 0;
    for(auto x:zz.get(N)) {
        ans += x.first*x.second;
    }
    cout << ans << endl;
}
0