abc292C题解
题目大意
给定一个整数
注意,
思路
对于每一个
所以答案为
其中
不难发现,
所以只需预处理出
代码
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int n,i;
int yin[229028]={0,1};
LL ans;
void zhiyin(int x)
{
int ans=1,x1=x;
for(int i=2;i<=sqrt(x);i++)
{
int temp=0;
while(x1%i==0)
{
x1/=i;
temp++;
}
ans=ans*(temp+1);
}
if(x1==x) yin[x]=min(2,x);
else if(x1>1) yin[i]=ans*2;
else yin[x]=ans;
return ;
}
int main()
{
cin>>n;
for(i=2;i<n;i++) zhiyin(i);
for(i=1;i<n;i++) ans+=yin[i]*yin[n-i];
cout<<ans;
return 0;
}
证明
设
其中
那么,所有的拆分方案为
易得个数为
证毕。