結果
問題 |
No.1514 Squared Matching
|
ユーザー |
![]() |
提出日時 | 2025-07-07 01:34:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 683 ms / 4,000 ms |
コード長 | 949 bytes |
コンパイル時間 | 2,210 ms |
コンパイル使用メモリ | 109,368 KB |
実行使用メモリ | 204,636 KB |
最終ジャッジ日時 | 2025-07-07 01:34:23 |
合計ジャッジ時間 | 14,433 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <iostream> #include <math.h> #include <numeric> #include <vector> const int MAXN = 50'000'000; void solve() { int n; std::cin >> n; std::vector<int> squarefree(n + 1); std::vector<bool> isPrime(n + 1, true); std::iota(squarefree.begin(), squarefree.end(), 0); isPrime[0] = isPrime[1] = false; for (int i = 2; i * i <= n; i++) { if (!isPrime[i]) { continue; } int k = i * i; for (int j = k; j * j <= n; j += i) { isPrime[j] = false; } for (int j = k; j <= n; j += k) { while (squarefree[j] % k == 0) { squarefree[j] /= k; } } } int res = 0; for (int i = 1; i <= n; i++) { res += (int) std::sqrt(n / squarefree[i]); } std::cout << res << std::endl; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); solve(); return 0; }