Problem description to split an even number into two different primes, and how many are there? Input inputs contain positive even numbers that do not exceed 10000, the number does not exceed 500, and if 0 is the end. Output corresponds to each even number, and outputs the numbers that are split into different primes, one for each row. Sample Input30260 Sample Output32 first hit the prime table, another one to judge, water do not know why, compile errors
#include <cstdio>#include<iostream>#include<cmath>using namespacestd;intprime[10000];voidInit_prime () {intI, J; for(i =2; I <= sqrt (10001.0); ++i) {if(!Prime[i]) for(j = i * I; J <10001; J + =i) prime[j]=1; } J=0; for(i =2; I <=10001; ++i)if(!Prime[i]) prime[j++] =i;}BOOLFintNinti) { intt = N-Prime[i]; for(intj = i +1;p Rime[j] < n;j++) if(t = = Prime[j])return true; return false;}intMain () {intN; Init_prime (); while(Cin >>N) { if(N = =0) Break; intn =0; for(inti =0;p Rime[i] < N/2; i++){ if(f (n,i)) n++; } cout<< N <<Endl; } //System ("pause"); return 0;}
Choose the wrong language, embarrassed ....
HDU Choose c + +!!!
HDU 2098 split Prime and