UVA - 10539Almost Prime Numbers
Almost Prime Numbers Def of Almost Prime Numbers: 自身不是素数,但只有一个素数因子, 由唯一分解定理可得,这样的数只能是 p c ( c > = 2 ) p^c(c>=2) p c ( c > = 2 ) Solution1: # include <stdio.h> # include <iostream> # include <cmath> # include <math.h> # include <string> # include <string.h> # include <algorithm> # define ll long long using namespace std ; const int maxn = 1e6 + 10 ; //欧拉筛法( O(n) ) int np = 0 , p [ maxn ] , v [ maxn + 10 ] ; int gg ( int n ) { for ( int i = 2 ; i <= n ; i ++ ) { if ( ! v [ i ] ) p [ ++ np ] = i ; //此时的i为某个质数 for ( int j = 1 ; j <= np && i * p [ j ] <= n ; j ++ ) { v [ i * p [ j ] ] = 1 ; /