zoukankan      html  css  js  c++  java
  • 高效素数打表

    #include <bits/stdc++.h>
    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cmath>
    #include <cstring>
    #include <vector>
    #include <map>
    #include <set>
    #include <bitset>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <iomanip>
    #include <cstdlib>
    using namespace std;
    #define is_lower(c) (c>='a' && c<='z')
    #define is_upper(c) (c>='A' && c<='Z')
    #define is_alpha(c) (is_lower(c) || is_upper(c))
    #define is_digit(c) (c>='0' && c<='9')
    #define min(a,b) ((a)<(b)?(a):(b))
    #define max(a,b) ((a)>(b)?(a):(b))
    #define IO ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define For(i,a,b) for(int i = a; i <= b; i++)
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int,int> pii;
    typedef pair<ll,ll> pll;
    typedef vector<int> vi;
    const ll inf=0x3f3f3f3f;
    const double EPS=1e-10;
    const ll inf_ll=(ll)1e18;
    const ll maxn=100005LL;
    const ll mod=1000000007LL;
    const int N = 2000+5;
    
    const int maxn 10000000
    bool visit[maxn+1000000];
    int prime[maxn],n;
    void getprime()
    {
    memset(visit, false, sizeof(visit));
    int num = 0;
    for (int i = 2; i <= maxn; ++i)
    {
    if ( !visit[i] )
    prime[++num] = i;
    for (int j = 1; j <= num && i * prime[j] <= n ; j++)
    {
    visit[ i * prime[j] ] = true;
    if (i % prime[j] == 0) break;
    }
    }
    }
    int main()
    {
    scanf("%d",&n);
    getprime();
    return 0;
    }
    宝剑锋从磨砺出 梅花香自苦寒来
  • 相关阅读:
    【转】iPython入门技巧
    Python——IPython和NumPy
    Python——类与对象,异常处理
    Python——函数,模块,简单文件读写
    给对象的key 设置成变量
    antd 表单validateFields validateFieldsAndScroll方法不执行
    css 设置禁用
    where与having区别
    重温robotframework--day1
    Linux下查看文件内容的命令
  • 原文地址:https://www.cnblogs.com/GHzcx/p/8585768.html
Copyright © 2011-2022 走看看