#include<stdio.h>#include<string.h>#definemaxn 1000000intisprime[maxn+10];intprime[maxn/10];intcount;intn;intmain() {while(scanf("%d",&n)!=EOF) { count=0;for(inti=0;i<=maxn+10;i++) isprime[i]=0;for(inti=2; i<=n; i++) {if(isprime[i]==0) { prime[count++]=i;fo...
1/* 2线性时间求出1-N 的素数 , 时间复杂度为O( N) ; 3一个合数可以表示成若干个素数的积 4比如说 i = 6 =2 * 3 , A = p1 * p2 * p3 .. * pn , 其中pi为素数 ,p1最小 , 只筛到p1 * i即可 5我们只筛 最小的 2 * i 不筛3 * i ; 6*/ 7#include <stdio.h> 8#include <...
这里用前缀和处理一下就可以再O(1)的时间复杂度情况查出了。 /*Keep on going Never give up*/ #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> const int maxn = 1e7; const int MaxN = 0x3f3f3f3f; const int MinN = 0xc0c0c00c; typedef long long ll; const int m...