結果

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

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll ans = 0;

int main() {
  ll N;
  cin >> N;
  assert(2 <= N && N <= 10000000000);
  for (ll i = 2; i < 100000; i++) {
    bool is_div = false;
    for (ll j = 2; j <= sqrt(i); j++) {
      if (i % j == 0) {
        is_div = true;
        break;
      }
    }
    if (!is_div) {
      ll now = i * i;
      while (now <= N) {
        ans += now;
        now *= i;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
0