結果

問題 No.1514 Squared Matching
ユーザー keijakkeijak
提出日時 2021-05-22 01:31:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,108 ms / 4,000 ms
コード長 989 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 195,204 KB
実行使用メモリ 247,692 KB
最終ジャッジ日時 2024-04-18 17:18:43
合計ジャッジ時間 21,409 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
53,596 KB
testcase_01 AC 1,101 ms
247,640 KB
testcase_02 AC 15 ms
53,472 KB
testcase_03 AC 14 ms
52,352 KB
testcase_04 AC 13 ms
52,608 KB
testcase_05 AC 14 ms
52,352 KB
testcase_06 AC 29 ms
55,296 KB
testcase_07 AC 213 ms
89,856 KB
testcase_08 AC 1,058 ms
240,684 KB
testcase_09 AC 918 ms
217,436 KB
testcase_10 AC 1,004 ms
231,172 KB
testcase_11 AC 1,054 ms
239,496 KB
testcase_12 AC 1,108 ms
243,804 KB
testcase_13 AC 1,090 ms
245,896 KB
testcase_14 AC 1,103 ms
246,796 KB
testcase_15 AC 1,103 ms
247,564 KB
testcase_16 AC 1,099 ms
247,556 KB
testcase_17 AC 1,096 ms
247,688 KB
testcase_18 AC 1,096 ms
247,692 KB
testcase_19 AC 1,107 ms
247,644 KB
testcase_20 AC 1,101 ms
247,644 KB
testcase_21 AC 1,108 ms
247,648 KB
testcase_22 AC 224 ms
93,020 KB
testcase_23 AC 435 ms
130,560 KB
testcase_24 AC 649 ms
169,560 KB
testcase_25 AC 872 ms
210,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP_(i, a_, b_, a, b, ...) \
  for (int i = (a), END_##i = (b); i < END_##i; ++i)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(x) std::begin(x), std::end(x)
using i64 = long long;

using namespace std;

char p[50000005];
int b[50000005];

auto solve() {
  i64 n;
  cin >> n;
  fill(ALL(p), 1);
  //   vector<char> p(n + 1, true);
  //   vector<int> b(n + 1);
  p[0] = p[1] = false;
  REP(i, n + 1) b[i] = i;
  for (int i = 4; i <= n; i += 2) {
    p[i] = false;
    while ((b[i] & 3) == 0) b[i] >>= 2;
  }
  for (i64 i = 3; i * i <= n; i += 2) {
    if (not p[i]) continue;
    i64 ii = i * i;
    for (int j = ii; j <= n; j += ii) {
      p[j] = false;
      while ((b[j] % ii) == 0) b[j] /= ii;
    }
  }
  i64 ans = 0;
  for (i64 x = 1; x <= n; ++x) {
    i64 r = std::sqrt(n / b[x]);
    ans += r;
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  cout << solve() << "\n";
}
0