3164 質因數分解

題目描述 Description

(多數據)給出t個數,求出它的質因子個數。

數據沒坑,難度降低。

輸入描述 Input Description

第一行 t

之後t行 數據

輸出描述 Output Description

t行 分解後結果(質因子個數)

樣例輸入 Sample Input

2

11

6

樣例輸出 Sample Output

1

2

數據範圍及提示 Data Size & Hint

(樣例解釋)11自己本身是一個質數,所以計入其中。

順便提示:t<=100000。每個數小於long long unsigned 呵呵





#include<iostream>
#include<cstdio>
#include<limits.h>
using namespace std;
int main(){
	long long unsigned n;
	int k;
	cin>>k;
	while(cin>>n){
		int i=2;
		int cnt=0;
		while(n!=1){
			
			if(n%i==0){
				cnt++;
				n/=i;
				continue;
			}
			i++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}


發佈了188 篇原創文章 · 獲贊 78 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章