文章

70

粉丝

0

获赞

57

访问

6.4k

头像
质因数个数 题解:
P1156 清华大学上机题
发布于2026年2月2日 12:01
阅读数 31

#include<iostream>

using namespace std;

void check(int x) {
	int cnt = 0;
	for (int i = 2; i * i <= x; i ++ ) {
		if (x % i == 0) {
			while (x % i == 0) {
				cnt ++ ;
				x /= i;
			}
		}
		
	}
	if (x > 1) cnt ++ ;
	cout << cnt << endl;
}

int main() {
    
	int n;
	while (cin >> n) {
	    check(n);
	}
	
	return 0;				
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发