結果

問題 No.3296 81-like number
コンテスト
ユーザー The Forsaking
提出日時 2025-10-18 18:32:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 1,898 ms
コンパイル使用メモリ 194,356 KB
実行使用メモリ 7,892 KB
最終ジャッジ日時 2025-10-18 18:32:30
合計ジャッジ時間 3,194 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
const int N = 2000086, MOD = 998244353, INF = 0x3f3f3f3f;
int n, m, w[N];


char s[N];

int primes[N], cnt;
bool st[N];
inline void init() {
    for (int i = 2; i < N; i++) {
        if (!st[i]) primes[cnt++] = i;
        for (int j = 0; primes[j] * (ll)i < N; j++) {
            st[i * primes[j]] = 1;
            if (i % primes[j] == 0) break;
        }
    }
}

int main() {
    init();
    ll n, res = 0;
    cin >> n;
    for (int i = 0; (ll)primes[i] * primes[i] <= n; i++)
        for (ll j = (ll)primes[i] * primes[i]; j <= n; j *= primes[i])
            res += j;
    printf("%lld\n", res);
    return 0;
}
0