結果
問題 |
No.3296 81-like number
|
ユーザー |
![]() |
提出日時 | 2025-08-16 17:59:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 559 bytes |
コンパイル時間 | 1,782 ms |
コンパイル使用メモリ | 198,344 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-08-17 14:00:05 |
合計ジャッジ時間 | 3,305 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll=long long; int main(){ ll n,sum=0; cin >> n; // 2000000 未満の素数を列挙する -> p vector<bool> f(2000000,true); f[0]=f[1]=false; for(int i=2;i<2000000;i++){ int j=2; while(i*j<2000000){ f[i*j]=false; j++; } } vector<ll> p; for(ll x=2;x*x<=n;x++) if(f[x]) p.push_back(x); for(ll x:p){ ll k=x*x; while(k<=n){ sum+=k; k*=x; } } cout << sum << endl; }