結果

問題 No.3296 81-like number
ユーザー Tyto alba
提出日時 2025-11-04 00:48:00
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 88 ms / 2,000 ms
+ 468µs
コード長 857 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 731 ms
コンパイル使用メモリ 107,328 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2026-11-12 16:56:25
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int64_t n, ans=0;
    int i, j, k;
    bool flg = true;
    vector<int> sosu;

    cin >> n;

    int n_ma = sqrt(n);
    for (i=2; i<=n_ma; i++) {
        if (i == 2){
            sosu.push_back(i);
            k = 2;
            while (pow(i, k) <= n) {
                ans += pow(i, k);
                k++;
            }
            continue;
        }

        for (j=0; j<sosu.size(); j++) {
            if (i % sosu[j] == 0) {
                flg = false;
                break;
            }
        }

        if (flg) {
            sosu.push_back(i);
            k = 2;
            while (pow(i, k) <= n) {
                ans += pow(i, k);
                k++;
            }
            
        }
        flg = true;
    }

    cout << ans << endl;
}
0