HDU 2098 分拆素数和
2014-11-17 13:26
471 查看
呃呃呃。很水的一道题,没什么说的,打表,然后筛出来符合条件的解就可以了,多多借助变量之间特殊的关系进行表示会达到简化的目的。
# include<cstdio> # include<iostream> # include<cstring> using namespace std; # define MAX 10000 int hash[MAX+10]; void dabiao() { memset(hash,0,sizeof(hash)); hash[0] = 1; hash[1] = 1; for ( int i = 2;i < MAX;i++ ) { //if (i > MAX/i ) continue;//如果数据大的话,就要这样处理,防止爆int if ( !hash[i] ) { for ( int j = i*i;j < MAX;j+=i ) { hash[j] = 1; } } } } int main(void) { dabiao(); int n; while ( (cin>>n)&&n ) { int ans = 0; for ( int i = 2;i < n/2;i++ ) { if ( hash[i]==0 && hash[n-i]==0 )ans++; } cout<<ans<<endl; //dabiao(); } return 0; }
相关文章推荐
- 【HDU 2098】 分拆素数和 (~水)
- Hdu 2098 分拆素数和
- [HDU](2098)分拆素数和---穷举法和哥德巴赫猜想
- 分拆素数和(http://acm.hdu.edu.cn/showproblem.php?pid=2098)
- HDU 1262 寻找素数对 2098分拆素数和
- HDU 2098 分拆素数和 遍历+素数打表
- hdu 2098 分拆素数和
- HDU 2098 分拆素数和
- HDU 2098 分拆素数和
- hdu 2098 分拆素数和
- hdu 2098 分拆素数和
- hdu 2098 分拆素数和(水题)
- HDU 2098 分拆素数和 (素数基础)
- HDU 2098 分拆素数和
- HDU2098——分拆素数和
- hdu 分拆素数和 2098
- hdu 2098 分拆素数和
- HDU - 2098-分拆素数和
- hdu 2098 分拆素数和 悲剧超时了。
- hdu 2098 分拆素数和 水题