結果
| 問題 |
No.3296 81-like number
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-05 16:29:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,508 bytes |
| コンパイル時間 | 1,734 ms |
| コンパイル使用メモリ | 195,644 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-10-05 16:29:45 |
| 合計ジャッジ時間 | 2,410 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 6 WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
// #include <atcoder/all>
#include <ranges>
// using namespace atcoder;
/* alias */
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
/* define short */
#define pb push_back
#define mp make_pair
#define all(obj) (obj).begin(), (obj).end()
#define YESNO(bool) \
if (bool) { \
cout << "YES" << endl; \
} else { \
cout << "NO" << endl; \
}
#define yesno(bool) \
if (bool) { \
cout << "yes" << endl; \
} else { \
cout << "no" << endl; \
}
#define YesNo(bool) \
if (bool) { \
cout << "Yes" << endl; \
} else { \
cout << "No" << endl; \
}
/* REP macro */
#define rep(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define reps(i, a, n) for (ll i = (a); i <= (ll)(n); ++i)
template <typename T>
inline bool chmax(T& a, const T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
// 座標を表す構造体
struct Point {
int y, x;
// コンストラクタを追加
Point(int y_ = 0, int x_ = 0) : y(y_), x(x_) {}
// <
bool operator<(const Point& other) const {
if (y != other.y)
return y < other.y;
return x < other.x;
}
// == 一致確認
bool operator==(const Point& other) const {
return y == other.y && x == other.x;
}
};
/*
エラトステネスの篩
O(N)未満で素数判定を行う
N以下の整数に対して素数判定
nが素数ならば isp(n)=true、そうでなければ isp(n)=false
参考: https://qiita.com/sakofsuken/items/210e082169daba690570
*/
ll sum = 0;
ll upper;
const ll N = pow(10, 5);
vector<bool> isp(N + 1, true);
// vll add_list;
void sieve() {
isp[0] = false;
isp[1] = false;
for (long long i = 2; pow(i, 2) <= N; i++) {
if (isp[i]) {
for (long long j = 2; i * j <= N; j++)
isp[i * j] = false;
// nの累乗の総和をとる
for (long long j = i * i; j <= upper; j *= i) {
sum += j;
// add_list.pb(j);
}
}
}
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> upper;
sieve();
cout << sum << endl;
return 0;
}