From dc1f0c4c0096013799416664894c5194dc7e1f52 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 28 Feb 2025 23:13:39 +0800 Subject: chore(store): move everything to store. --- works/life/algorithm-experiment/1.2.cpp | 73 --------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 works/life/algorithm-experiment/1.2.cpp (limited to 'works/life/algorithm-experiment/1.2.cpp') diff --git a/works/life/algorithm-experiment/1.2.cpp b/works/life/algorithm-experiment/1.2.cpp deleted file mode 100644 index ab49f6a..0000000 --- a/works/life/algorithm-experiment/1.2.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include -#include -#include - -const int MAXN = 2000000000; -long long pri[100000000]; -std::bitset vis; -int cnt = 0; - -void init() { - for (int i = 2; i < MAXN; ++i) { - if (!vis[i]) { - pri[cnt++] = i; - vis[i] = true; - } // vis[i]置为true或不置true都可以 - for (int j = 0; j < cnt; ++j) { - if (i * pri[j] >= MAXN) //判断是否越界 - break; - vis[i * pri[j]] = true; //筛数 - if (i % pri[j] == 0) //时间复杂度为O(n)的关键! - break; - } - } -} - -int main() { - init(); - - while (!std::cin.eof()) { - long long n; - std::cin >> n; - - bool b = false; - - if (n == 1 || n == 0) { - continue; - } - - if (std::binary_search(pri, pri + cnt, n)) { - std::cout << n << '\n'; - continue; - } - - for (int i = 0; i < cnt; i++) { - if (n % pri[i] == 0) { - b = true; - break; - } - } - - if (b) - continue; - - long long m = std::sqrt(n); - - for (long long i = pri[cnt - 1] + 2; i <= m; i += 2) { - if (n % i == 0) { - b = true; - break; - } - } - - if (!b) { - std::cout << n << '\n'; - } - - std::cin >> std::ws; - } - - return 0; -} \ No newline at end of file -- cgit v1.2.3