結果
| 問題 |
No.1514 Squared Matching
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-21 22:28:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 675 bytes |
| コンパイル時間 | 912 ms |
| コンパイル使用メモリ | 74,644 KB |
| 最終ジャッジ日時 | 2025-01-21 15:40:49 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 MLE * 14 |
ソースコード
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using lint = long long;
void solve() {
lint n;
cin >> n;
vector<int> xs(n + 1);
iota(xs.begin(), xs.end(), 0);
for (int k = 2; k * k <= n; ++k) {
auto s = k * k;
if (xs[s] != s) continue;
for (int x = s; x <= n; x += s) {
while (xs[x] % s == 0) xs[x] /= s;
}
}
vector<lint> cnt(n + 1, 0);
for (int x = 1; x <= n; ++x) ++cnt[xs[x]];
lint ans = 0;
for (auto c : cnt) ans += c * c;
cout << ans << "\n";
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
solve();
return 0;
}