[poj] 3421 X-factor Chains
阿新 • • 發佈:2017-11-30
def esp pac cst href 質因子 scan bre mark include
include
}
return 0;
}
``
原題
就是n的所有質因子的全排列(是可重集全排列)
```cpp
include
include
define N 2020
typedef long long ll;
using namespace std;
ll jc[22],cnt,n,prime[N],ans,sum;
int num[N];
bool is[N];
int main()
{
jc[0]=1;
for (int i=1;i<=20;i++) jc[i]=jc[i-1]i;
for (int i=2;i<=2000;i++) is[i]=1;
for (int i=2;i<=2000;i++)
if (is[i])
{
prime[++cnt]=i;
for (int j=ii;j<=2000;j+=i)
is[j]=0;
}
while (~scanf("%lld",&n))
{
ans=0;
sum=0;
memset(num,0,sizeof(num));
for (int i=1;i<=cnt;i++)
{
if (n==1) break;
while (n%prime[i]==0) n/=prime[i],num[i]++,sum++;
}
if (n>1) sum++;
ans=jc[sum];
for (int i=1;i<=cnt;i++)
ans/=jc[num[i]];
printf("%lld %lld\n",sum,ans);
return 0;
}
``
[poj] 3421 X-factor Chains