結果

問題 No.3296 81-like number
ユーザー Rumain831
提出日時 2025-10-05 16:27:51
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 818 ms
コンパイル使用メモリ 78,812 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-05 16:27:58
合計ジャッジ時間 1,497 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main(void){
  ll n; cin >> n;
  int nn=1e5+1;
  vector<ll> yakusu(nn+1, -1), prime;
  for(int i=2; i<=nn; i++){
    if(yakusu[i]!=-1) continue;
    int copy=i;
    prime.push_back(i);
    while(copy<=nn){
      if(yakusu[copy]==-1) yakusu[copy]=i;
      copy+=i;
    }
  }
  ll ans=0;
  for(auto p:prime){
    if(p*p>n) break;
    ll now=p*p;
    while(now<=n) ans+=now, now*=p;
  }
  cout << ans << endl;
  return 0;
}
0