题意:
问有多少个素数对(a,b)满足a+b=n&&a<=b
思路:
素数筛一下就行了
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x&(-x))
typedef long long LL;
const int maxn = 100005;
const int inf=(1<<28)-1;
#define maxp 10000005
bool notprime[maxp];
int primes[700005];
void get_prime()
{
notprime[1]=true;
for(int i=2;i<maxp;++i)
if(!notprime[i])
{
primes[++primes[0]]=i;
for(LL j=(LL)i*i;j<maxp;j+=i)
notprime[j]=true;
}
}
int main()
{
get_prime();
//printf("%d\n",primes[0]);
int T,Case=0;
scanf("%d",&T);
while(T--)
{
int n;
scanf("%d",&n);
int Ans=0;
for(int i=1;primes[i]<=n/2;++i)
if(!notprime[n-primes[i]]) Ans++;
printf("Case %d: %d\n",++Case,Ans);
}
return 0;
}