「一本通 6.3 练习 1」X-factor Chain

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL f[30]; int c[1200000];
int main(){
    int x; f[0]=1;
    for(int i=1;i<=20;++i)
    f[i]=i*f[i-1];
    while(~scanf("%d",&x)){
        int tot=0; LL ans; c[0]=0;
        for(int i=2;i*i<=x;++i){
            if(x%i==0){
                c[++c[0]]=0;
                while(x%i==0){x/=i; c[c[0]]++;}
                tot+=c[c[0]];
            }
        }
        if(x>1) c[++c[0]]=1,tot++;
        ans=f[tot];
        for(int i=1;i<=c[0];++i)
        ans/=f[c[i]];
        printf("%d %lld
",tot,ans);
    }
    return 0;
}
    
原文地址:https://www.cnblogs.com/huihao/p/11746341.html