#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
const int N=1e4+10;
void get_primes(int n);
int n;
LL res;
bool st[N];
int primes[N], cnt;
signed main()
{
get_primes(N);
cin>>n;
for(int i=n/2;i<=n;i++)
if(!st[i]&&!st[n-i])
{
cout<<i*(n-i)<<endl;//和为定值的两个数,越接近积越大,因此从中间拆分
break;
}
}
void get_primes(int n)
{
for(int i=2;i<=n;i++)
{
if(!st[i]) primes[cnt++]=i;
for(int j=0;primes[j]<=n/i;j++)
{
st[i*primes[j]]=true;
if(i%primes[j]==0) break;
}
}
}
质数的和与积
最新推荐文章于 2023-05-01 16:40:20 发布