zoukankan      html  css  js  c++  java
  • CODE[VS] 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 呵呵

    刚刚没忍住,去看了丁丁当年好声音的辛德瑞拉,太好听了。

    还有毛晓彤前阵子在跨界歌王上的辛德瑞拉,哇,没想到没想到哇。

    加油,好好爱自己,不要理那些流言蜚语。

    数学好题啊。

    刚开始确实想到唯一分解定理了,

    不过想cha pi了。

    zz的想成要么一个要么两个,质数一个,其他都俩了、、

    哇塞,这样居然还能过俩点。

    正解思路???

    就挨着辗转除就好了嘛。

    为什么?

    举个例子手算一下就好了嘛。

    下面看ac代码:

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cmath>
     4 #include<algorithm>
     5 #include<cstring>
     6 using namespace std;
     7 
     8 long long n,a,ans;
     9 
    10 int main()
    11 {
    12     scanf("%lld",&n);
    13     for(int i=1;i<=n;++i)
    14     {
    15         ans=0;
    16         scanf("%lld",&a);
    17         for(long long j=2;j<=sqrt(a);++j)
    18             while(a%j==0)
    19             {
    20                 a/=j;
    21                 ans++;
    22             }
    23         if(a!=1) ans++;
    24         printf("%d
    ",ans);
    25     }
    26     return 0;
    27 }
  • 相关阅读:
    第一章 新手入门
    Excle生成T层加工ODS层存储过程
    Excel生成建表角本
    数据仓库建模技巧
    算法第四章作业
    删数问题
    算法第三章作业
    第三章上机实践报告
    第二章作业
    Thinkphp6框架学习:($this->error()undefined)Call to undefined method appindexcontrollerAdmin::error()
  • 原文地址:https://www.cnblogs.com/Mary-Sue/p/9168616.html
Copyright © 2011-2022 走看看