Split Prime and time limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 20301 accepted submission (s): 8854
Problem description splits an even number into two sums of different prime numbers. How can we split them?
The input contains some positive and even numbers. The input value does not exceed 10000, And the number does not exceed 500. In case of 0, it ends.
Output corresponds to each even number. The output is split into numbers of different prime numbers, and each result occupies one row.
Sample Input
30260
Sample output
32
#include <stdio.h>#include <math.h>#define maxn 10002int prime[maxn] = {1, 1};int main(){int i, n, j, ans;n = sqrt(maxn);for(i = 2; i <= n; ++i){if(prime[i]) continue;for(j = i * i; j <= maxn; j += i)prime[j] = 1;}while(scanf("%d", &n), n){j = n >> 1; ans = 0;for(i = 2; i < j; ++i)if(!prime[i] && !prime[n - i]) ++ans;printf("%d\n", ans);}return 0;}