結果
| 問題 | No.1514 Squared Matching |
| コンテスト | |
| ユーザー |
kyo1
|
| 提出日時 | 2022-06-05 03:53:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 627 bytes |
| 記録 | |
| コンパイル時間 | 2,119 ms |
| コンパイル使用メモリ | 196,804 KB |
| 最終ジャッジ日時 | 2025-01-29 18:23:37 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 TLE * 17 MLE * 1 |
ソースコード
#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;
}
kyo1