結果

問題 No.1514 Squared Matching
ユーザー kyo1kyo1
提出日時 2022-06-05 03:53:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 627 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 204,808 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 02:58:59
合計ジャッジ時間 7,891 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int64_t> X(N + 1, 0);
  iota(X.begin(), X.end(), 0);
  vector<bool> Y(N + 1, true);
  for (int64_t i = 2; i <= N; i++) {
    if (!Y[i]) continue;
    for (int64_t j = i; j <= N; j += i) {
      while (X[j] % (i * i) == 0) {
        X[j] /= i * i;
      }
      Y[j] = false;
    }
  }
  vector<int64_t> Z(N + 1, 0);
  for (int i = 0; i <= N; i++) {
    Z[X[i]]++;
  }
  int64_t res = 0;
  for (int i = 1; i <= N; i++) {
    res += Z[i] * Z[i];
  }
  cout << res << '\n';
  return 0;
}
0