1751:分解因数

1751:分解因数

总时间限制: 
1000ms
 
内存限制: 
65536kB
描述
给出一个正整数a,要求分解成若干个正整数的乘积,即a = a1 * a2 * a3 * ... * an,并且1 < a1 <= a2 <= a3 <= ... <= an,问这样的分解的种数有多少。注意到a = a也是一种分解。
输入
第1行是测试数据的组数n,后面跟着n行输入。每组测试数据占1行,包括一个正整数a (1 < a < 32768)
输出
n行,每行输出对应一个输入。输出应是一个正整数,指明满足要求的分解的种数
样例输入
2
2
20
样例输出
1
4
 1 #include<iostream>
 2 #include<cmath>
 3 #include<cstdio>
 4 using namespace std;
 5 int tot=0;
 6 int find(int a,int b)
 7 {
 8     for(int i=b;i<=sqrt(a);++i)
 9     {
10         if(a%i==0)//找到可以被分解的数
11         find(a/i,i);
12     }
13     tot++;
14 }
15 int main()
16 {
17     int n;
18     cin>>n;
19     for(int i=1;i<=n;i++)
20     {
21         tot=0;
22         int a;
23         cin>>a;
24         find(a,2);    
25         cout<<tot<<endl;
26     }
27     return 0;
28 }

 

posted @ 2017-03-09 21:06  自为风月马前卒  阅读(752)  评论(0编辑  收藏  举报

Contact with me