ks = [[] for _ inrange(MX)] # ks[x] 为 x 分解质因数后,每个质因数的个数列表 for i inrange(2, MX): p, x = 2, i while p * p <= x: if x % p == 0: k = 1 x //= p while x % p == 0: k += 1 x //= p ks[i].append(k) p += 1 if x > 1: ks[i].append(1)
classSolution: defidealArrays(self, n: int, maxValue: int) -> int: ans = 0 for x inrange(1, maxValue + 1): mul = 1 for k in ks[x]: mul = mul * comb(n + k - 1, k) % MOD ans += mul return ans % MOD
static { for (vari=1; i < MX; i++) { ks[i] = newArrayList<Integer>(); varx= i; for (varp=2; p * p <= x; ++p) { if (x % p == 0) { vark=1; for (x /= p; x % p == 0; x /= p) ++k; ks[i].add(k); } } if (x > 1) ks[i].add(1); }
publicintidealArrays(int n, int maxValue) { varans=0L; for (varx=1; x <= maxValue; ++x) { varmul=1L; for (var k : ks[x]) mul = mul * c[n + (int) k - 1][(int) k] % MOD; ans += mul; } return (int) (ans % MOD); } }
int init = []() { for (int i = 2; i < MX; ++i) { int x = i; for (int p = 2; p * p <= x; ++p) { if (x % p == 0) { int k = 1; for (x /= p; x % p == 0; x /= p) ++k; ks[i].push_back(k); } } if (x > 1) ks[i].push_back(1); }
classSolution { public: intidealArrays(int n, int maxValue){ long ans = 0L; for (int x = 1; x <= maxValue; ++x) { long mul = 1L; for (int k: ks[x]) mul = mul * c[n + k - 1][k] % MOD; ans += mul; } return ans % MOD; } };
funcinit() { for i := 2; i < mx; i++ { x := i for p := 2; p*p <= x; p++ { if x%p == 0 { k := 1 for x /= p; x%p == 0; x /= p { k++ } ks[i] = append(ks[i], k) } } if x > 1 { ks[i] = append(ks[i], 1) } }
c[0][0] = 1 for i := 1; i < len(c); i++ { c[i][0] = 1 for j := 1; j <= mxK && j <= i; j++ { c[i][j] = (c[i-1][j] + c[i-1][j-1]) % mod } } }
funcidealArrays(n, maxValue int) (ans int) { for _, ks := range ks[1 : maxValue+1] { mul := 1 for _, k := range ks { mul = mul * c[n+k-1][k] % mod } ans = (ans + mul) % mod } return ans }