結果
問題 |
No.3296 81-like number
|
ユーザー |
![]() |
提出日時 | 2025-10-05 13:41:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 1,307 bytes |
コンパイル時間 | 3,982 ms |
コンパイル使用メモリ | 255,696 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-10-05 13:42:14 |
合計ジャッジ時間 | 5,054 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 |
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #define chmin(x,y) (x) = min((x),(y)) #define chmax(x,y) (x) = max((x),(y)) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define vec vector #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define pb push_back #define eb emplace_back using namespace std; using namespace atcoder; using ll = long long; using ld = long double; const ll mod = 998244353; using mint = modint998244353; const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1}; // using Graph = vector<vector<pair<int,ll>>>; using Graph = vector<vector<int>>; ll pow_ll(ll p, int n){ ll res = 1; rep(i,n) res *= p; return res; } int main(){ // input ll N; cin >> N; // prep const int M = 100000; vector<int> is_p(M+1,0); for(int x = 2; x <= M; x++){ int z = x; for(int y = 2; y * y <= z; y++){ if(z % y == 0){ z /= y; break; } } if(z == x) is_p[x] = 1; } // solve ll ans = 0; set<ll> st; for(int n = 2; (1LL<<n) <= N; n++){ for(int p = 2; p < M; p++){ if(!is_p[p]) continue; ll X = pow_ll(p,n); if(X > N) break; if(!st.count(X)){ // cerr << X << "\n"; ans += X; } st.insert(X); } } // output cout << ans << endl; }