一道很水的题,但是一开始WA了两次,傻逼题,变成傻逼了,,,,先打表,然后查表就好,不停的枚举,注意终止的条件,简单的不等式放缩和带入就好
原因是应该用!,却用成了~,,,,QAQ
# include<cstdio> # include<iostream> # include<cstring> using namespace std; # define MAX 10006 int hash[MAX]; void dabiao() { memset(hash,0,sizeof(hash)); hash[0] = 1; hash[1] = 1; for ( int i = 2;i < MAX;i++ ) { if ( ~hash[i] ) { for ( int j = 2*i;j < MAX;j+=i ) { hash[j] = 1; } } } } int main(void) { dabiao(); int n; while (cin>>n) { int ans = 0; for ( int i = 2;i <= n;i++ ) { for ( int j = i;j <= (n-i)/2;j++ ) { if ( (!hash[i])&&(!hash[j])&&(!hash[n-i-j]) ) ans++; } } cout<<ans<<endl; } return 0; }