标签:include oid while def sqrt ret force pac line
sol:很显然就是找出所有质因数,然后分别塞进去就行了,怎么塞就是组合数。感觉就是道小学奥数题
#include <bits/stdc++.h> using namespace std; typedef int ll; inline ll read() { ll s=0; bool f=0; char ch=‘ ‘; while(!isdigit(ch)) {f|=(ch==‘-‘); ch=getchar();} while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();} return (f)?(-s):(s); } #define R(x) x=read() inline void write(ll x) { if(x<0) {putchar(‘-‘); x=-x;} if(x<10) {putchar(x+‘0‘); return;} write(x/10); putchar((x%10)+‘0‘); } #define W(x) write(x),putchar(‘ ‘) #define Wl(x) write(x),putchar(‘\n‘) const int Mod=1000000007; int n; map<int,int>Map; int num[1000005],cnt[1000005]; int fac[15505],invf[15505]; inline int ksm(int x,int y) { int ans=1; while(y) { if(y&1) ans=1LL*ans*x%Mod; x=1LL*x*x%Mod; y>>=1; }return ans; } inline int C(int n,int m) { int oo; oo=1LL*fac[n]*invf[m]%Mod*invf[n-m]%Mod; return oo; } int main() { freopen("codeforces396A_data.in","r",stdin); int i,j,k,x; R(n); fac[0]=invf[0]=1; for(i=1;i<=15500;i++) fac[i]=1LL*fac[i-1]*i%Mod; invf[15500]=ksm(fac[15500],Mod-2); for(i=15499;i>=1;i--) invf[i]=1LL*invf[i+1]*(i+1)%Mod; for(i=1;i<=n;i++) { R(x); for(j=2;j<=sqrt(x);j++) if(x%j==0) { int oo=0; while(x%j==0) {x/=j; oo++;} if(!Map[j]) { Map[j]=++(*num); num[*num]=j; cnt[*num]=oo; }else cnt[Map[j]]+=oo; } if(x>1) { if(!Map[x]) { Map[x]=++(*num); num[*num]=x; cnt[*num]=1; }else cnt[Map[x]]++; } } int ans=1; for(i=1;i<=*num;i++) { ans=1LL*ans*C(cnt[i]+n-1,n-1)%Mod; }Wl(ans); return 0; }
标签:include oid while def sqrt ret force pac line
原文地址:https://www.cnblogs.com/gaojunonly1/p/11318108.html