/* 对于java 另一种快的输入总是记不住!!就是背也要背下来!! 在网上的一段证明: n^b + p*n^(b-1) = m^b n^(b-1)*[n+p]=m^b 因为n里面要么有p因子,要么没有,所以 gcd(n^(b-1),n+p)=1或(含有p因子的数) 当gcd(n^(b-1),n+p)== (含有p因子的数)的时候,显然无解 因为 假设有解,那么n=K*p , K^(b-1) * p^b*(K+1) 如果希望上面的==m^b,那么K^(b-1) *(K+1)必须能表示成某个数X的b次方 而gcd(K,K+1)=1,所以他们根本就没共同因子,所以没办法表示成X的b次方 所以gcd(n^(b-1),n+p)=1 假设 n=x^b n+p=y^b 那么显然m=x^(b-1)*y 而 p=y^b-x^b 显然 (y-x)|p 那么必须有y-x=1 所以y=x+1 代上去就发现 p=(x+1)^b - x ^b 所以暴力枚举x,然后判断p是否是素数既可 */ import java.io.*; import java.util.*; import java.math.*; public class Main2866 { static final int N = 1000006; static int ans[] = new int[N]; static boolean hash[] = new boolean[N]; static int result[] = new int[N]; //public static void main(String[] args){ public static void main(String[] args) throws IOException{ Prime(); Sovle(); //Scanner cin = new Scanner(System.in); StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); //while(cin.hasNext()){ while(in.nextToken() != StreamTokenizer.TT_EOF){ int l; //l = cin.nextInt(); l = (int)in.nval; if(l < 7){ //System.out.println("No Special Prime!"); out.println("No Special Prime!"); continue; } //System.out.println(result[l]); out.println(result[l]); } out.flush(); } static void Prime(){ Arrays.fill(hash, (boolean)false); int tt = (int)Math.sqrt(1.0 * N); for(int i = 2; i < tt; i++) if(!hash[i]) for(int j = 2; j * i < N; j++) hash[i * j] = true; } static void Sovle(){ Arrays.fill(ans, (int)0); Arrays.fill(result, (int)0); int x = 0; while(true){ x++; int temp = (int)(Math.pow(1.0 * ( x + 1 ), 3.0) - (int)Math.pow(1.0 * x, 3.0)); if(temp > 1000000) break; if(!hash[temp]) ans[temp] = 1; } for(int i = 3; i < N - 5; i++) result[i] = result[i - 1] + ans[i]; } }