#include<bits/stdc++.h>
using namespace std;
int k;
void ac(int s,int m)
{
if(s==1)
{
k++;return ;
}//拆分数为1时,方案数加1,结束递归
else for(int i=m;i<=s;i++)
if(s%i==0)
{//s除以正整数i后继续拆分
ac(s/i,i);//正整数从i开始继续枚举
}
}
int main()
{int n;
cin>>n;
for(int i=1;i<=n;i++)
{
k=0;
int t;
cin>>t;
ac(t,2);//把将要拆分的数t传递给s,因子为1时会无限递归,所以从2开始
cout<<k<<endl;//输出方案数
}
return 0;
}
分解因数(2)
于 2018-02-27 13:19:55 首次发布