其他分享
首页 > 其他分享> > 因数的多少——解题报告

因数的多少——解题报告

作者:互联网

因子数

【1,n】中的数进行余数的判断,若为0,则是它的一个因数,对应的优化便是【1,sqrt(n)】的判断

1,返回因子数

返回因子数
题目的意思是:一个数只含有2,3,5,7因子,返回它包含的因子数

#include<cstdio>
#define ll long long
int main() {
	ll n;
	int yueshu[4] = { 2,3,5,7 }; 
	while (scanf("%lld", &n) != EOF && n != 0) {       //输入的判定
		ll ans = 1;                          //结果
		for (int i = 0; i < 4; ++i) {
			int count = 0;
			for (; n % yueshu[i] == 0; n /= yueshu[i])
			    count++; //判断约数的个数
			ans *= count + 1;                               //公式
		}

		printf("%lld\n", ans);
	}
	return 0;
}
```![请添加图片描述](https://www.icode9.com/i/ll/?i=8f8af94e276d4805b4e6be3fe8b29fa1.png)


标签:count,int,ll,因数,因子,解题,yueshu,ans,多少
来源: https://blog.csdn.net/weixin_45920495/article/details/121063293