資源簡(jiǎn)介
Description
大于1的正整數(shù) n 都可以分解為 n = x1 * x2 * ... * xm
例如:當(dāng)n=12時(shí),共有8種不同的分解式:
12 = 12
12 = 6*2
12 = 4*3
12 = 3*4
12 = 3*2*2
12 = 2*6
12 = 2*3*2
12 = 2*2*3
對(duì)于給定正整數(shù)n,計(jì)算n共有多少種不同的分解式。
Input
第一行一個(gè)正整數(shù)n (1<=n<=1000000)
Output
不同的分解式數(shù)目
Sample Input
12
Sample Output
8
Hint
此題因子講順序的.第一個(gè)因子可能是2~n之間的數(shù).
代碼片段和文件信息
#include
using?namespace?std;
int?num=0;
void?f(int?m)
{
if(m==1)
num++;
else
for(int?i=m;i>=2;i--)
if(m%i==0)
f(m/i);
}
int?main()
{
int?n;
cin>>n;
f(n);
cout< return?0;
}
????
????????tle>未將對(duì)象引用設(shè)置到對(duì)象的實(shí)例。 tle>
????????ta?name=“viewport“?content=“width=device-width“?/>
????????yle>
?????????body?{font-family:“Verdana“;font-weight:normal;font-size:?.7em;color:black;}?
?????????p?{font-family:“Verdana“;font-weight:normal;color:black;margin-top:?-5px}
?????????b?{font-family:“Verdana“;font-weight:bold;color:black;margin-top:?-5px}
?????????H1?{?font-family:“Verdana“;font-weight:normal;font-size:18pt;color:red?}
?????????H2?{?font-family:“Verdana“;font-weight:normal;font-size:14pt;color:maroo
評(píng)論
共有 條評(píng)論