Topic Links:
Codeforces 396A
Main topic:
A sequence of n numbers is given, which is the same as the product of the sequence, but the number of the sequence itself is different.
Topic Analysis:
- Combinatorial math problem, for each number we can decompose it factorization, and then count the number of individual factorization of the whole sequence.
- Then the requirements of the sequence must be composed of these factorization (the number of each factorization remains unchanged), so we can use the combination of the plate method, each factorization divided into the number of n (there are some numbers not assigned to the case), then is C n? 1 Qualitybecausenumberanumber+N?1 。
- According to the multiplication principle, the total number of schemes is the product of the dividing number of each factorization.
AC Code:
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <map>#define MAX 30007using namespace STD;typedef Long LongLL;typedef map<int,ll>MIL;ConstLL mod =1e9+7; LL Fac[max],recfac[max];intn,a[max],mark[100007];mil MP; LL INV (ll num, ll x) {LL ret =1; while(x) {if(x&1) {ret *= num; RET%= mod; } num *= num; Num%= mod; X >>=1; }returnRET;}voidInit () {fac[0] =1; for(LL i =1; i < MAX; i++) {Fac[i] = fac[i-1]*i; Fac[i]%= mod; Recfac[i] = INV (Fac[i], mod-2); }memset(Mark,0,sizeof(Mark)); mark[1] = mark[0] =1; for(inti =2; I*i < MAX; i++) {if(Mark[i])Continue; for(intJ =i*i; J < MAX; J + = i) mark[j] =1; }}voidHandle (intNUM) { for(inti =2; I*i <= num; i++) {if(num%i)Continue;if(Mark[i])Continue; while(num%i = =0) {num/= i; mp[i]++; } }if(Num >1) mp[num]++;} LL C (intNintm) {if(M = =0)return 1;returnFac[n]*recfac[n-m]%mod*recfac[m]%mod;}intMain () {init (); while( ~scanf("%d", &n)) {mp.clear (); for(inti =0; I < n; i++) {scanf("%d", &a[i]); Handle (A[i]); } LL ans =1; Mil::iterator it = Mp.begin (); for(; it! = Mp.end (); it++) {intx = it->second; Ans *= C (x+n-1, N-1); Ans%= MoD; }printf("%lld\n", ans); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Codeforces 396A A. On number of decompositions to multipliers (combinatorial mathematics + number theory)