现在的位置: 首页 > 综合 > 正文

BestCoder Round #18 or HDU 5104

2018年04月29日 ⁄ 综合 ⁄ 共 505字 ⁄ 字号 评论关闭

    一道很水的题,但是一开始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;
}

【上篇】
【下篇】

抱歉!评论已关闭.