约数

#include<cstdio>
#include<cmath>
int slove(int x)
{
	int res,k,c,i;
	res=1;k=int(sqrt(x*1.0));i=1;
	while(++i<=k)
	{
		if(x%i) continue;
		c=1;
		do
		{
			x/=i,c++;
		}while(x%i==0);
		res*=c;
	}
	if(x>1) res<<=1;
	return res;
}
int sum(int x)
{
	int res,k,s,c,i;
	res=1;k=int(sqrt(x*1.0));i=1;
	while(++i<=k)
	{
		if(x%i) continue;
		s=c=1;
		do
		{
			x/=i,c*=i,s+=c;
		}while(x%i==0);
		res*=s;
	}
	if(x>1) res*=(x+1);
	return res;
}
int main()
{
	int x;
	scanf("%d",&x);
	printf("%d %d\n",slove(x),sum(x));
	return 0;
}//约数个数与和
posted @ 2020-08-30 08:33  study&work  阅读(141)  评论(0编辑  收藏  举报