From 2f70d9726398bb49d4f369fe718e16ca66d10b6f Mon Sep 17 00:00:00 2001 From: Luke Videckis Date: Fri, 22 Nov 2024 11:54:52 -0600 Subject: [PATCH] Golf (#105) * golf * fix * [auto-verifier] verify commit ba62ec791294942562b45218aad94a02e63b9681 --------- Co-authored-by: GitHub --- .verify-helper/timestamps.remote.json | 1 - library/math/prime_sieve/get_prime_factors.hpp | 5 ++--- tests/library_checker_aizu_tests/math/prime_sieve.test.cpp | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.verify-helper/timestamps.remote.json b/.verify-helper/timestamps.remote.json index fcf319fd..d7fb378e 100644 --- a/.verify-helper/timestamps.remote.json +++ b/.verify-helper/timestamps.remote.json @@ -96,7 +96,6 @@ "tests/library_checker_aizu_tests/math/n_choose_k.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/num_subsequences.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/partitions.test.cpp": "2024-11-17 14:04:03 -0600", -"tests/library_checker_aizu_tests/math/prime_sieve.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/solve_linear_mod.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/tetration.test.cpp": "2024-11-17 14:04:03 -0600", "tests/library_checker_aizu_tests/math/totient.test.cpp": "2024-11-17 14:04:03 -0600", diff --git a/library/math/prime_sieve/get_prime_factors.hpp b/library/math/prime_sieve/get_prime_factors.hpp index 1e728e50..7ea9284b 100644 --- a/library/math/prime_sieve/get_prime_factors.hpp +++ b/library/math/prime_sieve/get_prime_factors.hpp @@ -1,7 +1,6 @@ #pragma once #include "calc_sieve.hpp" -//! `fac` will equal all prime factors of num, increasing +//! `p` will be all prime factors of num, increasing //! @time O(log(num)) //! @space O(1) -for (int left = num, fac = sieve[left]; left > 1; - fac = sieve[left /= fac]) +for (int cpy = num, p; (p = sieve[cpy]) > 1; cpy /= p) \ No newline at end of file diff --git a/tests/library_checker_aizu_tests/math/prime_sieve.test.cpp b/tests/library_checker_aizu_tests/math/prime_sieve.test.cpp index a5620da5..af82e7f7 100644 --- a/tests/library_checker_aizu_tests/math/prime_sieve.test.cpp +++ b/tests/library_checker_aizu_tests/math/prime_sieve.test.cpp @@ -25,9 +25,9 @@ int main() { int prev_prime = -1; #include "../../../library/math/prime_sieve/get_prime_factors.hpp" { - assert(fac >= prev_prime); - prev_prime = fac; - curr[fac]++; + assert(p >= prev_prime); + prev_prime = p; + curr[p]++; } } for (auto [p, e] : curr)