結果

問題 No.3296 81-like number
ユーザー GOTKAKO
提出日時 2025-10-05 13:34:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 1,689 ms
コンパイル使用メモリ 198,000 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-05 13:35:49
合計ジャッジ時間 2,207 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    long long N; cin >> N;
    int Need = 200000;
    vector<bool> prime(Need+1,true);
    prime.at(0) = false; prime.at(1) = false;
    for(int i=2; i*i<=Need; i++){
        if(!prime.at(i)) continue;
        for(int k=i*i; k<=Need; k+=i) prime.at(k) = false;
    }
    long long answer = 0;
    for(long long a=2; a*a<=N; a++) if(prime.at(a)){
        long long v = a*a;
        while(v <= N) answer += v,v *= a;
    }
    cout << answer << endl;
}
0