3164 质因数分解
生活随笔
收集整理的這篇文章主要介紹了
3164 质因数分解
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
3164 質因數分解
?
?時間限制: 1 s ?空間限制: 256000 KB ?題目等級 : 黃金 Gold 題解 題目描述?Description(多數據)給出t個數,求出它的質因子個數。
數據沒坑,難度降低。
輸入描述?Input Description第一行 t
之后t行 數據
輸出描述?Output Descriptiont行 分解后結果(質因子個數)
樣例輸入?Sample Input2
11
6
樣例輸出?Sample Output1
2
數據范圍及提示?Data Size & Hint(樣例解釋)11自己本身是一個質數,所以計入其中。
順便提示:t<=100000。每個數小于long long unsigned?呵呵
#include<iostream> #include<cstdio> #include<cstring> #include<cmath>using namespace std; int n; long long x; void solve(long long a) {int p=0;for(long long i=2;i<=a;i++)if(a%i==0)while(a%i==0){a=a/i;p++;}printf("%d\n",p);} int main() {scanf("%d",&n);for(int i=1;i<=n;i++){scanf("%lld",&x);solve(x);}return 0; }?
轉載于:https://www.cnblogs.com/xiaoningmeng/p/5527560.html
總結
以上是生活随笔為你收集整理的3164 质因数分解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 模块(序列化(jsonpickle)+X
- 下一篇: we7 数据库