您的位置:首页 > 其它

hdu 1262 寻找素数对

2018-04-12 07:09 302 查看
打表 打表 打表

http://acm.hdu.edu.cn/showproblem.php?pid=1262

#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

const int MAXN = 10000;
int fun[MAXN];

void judge()
{
int temp,flag;
for(int i=2;i<MAXN;i++)
{
flag = 1;
temp = (int)(sqrt(i));
for(int j=2;j<=temp;j++)
{
if(i%j==0)
flag = 0;
}
if(flag) fun[i] = 1;
}
}

int main()
{
judge();

int n,half;

while(scanf("%d",&n)!=EOF)
{
half = n/2;
while(half>=2)
{
if(fun[half]&&fun[n-half])
{
printf("%d %d\n",half,n-half);
break;
}
half--;
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: