Problem:


Score : 300 points

Problem Statement

You are given an integer N.
Find the number of the positive divisors of N!, modulo 10^9+7.

Constraints

1≤N≤10^3

Input

The input is given from Standard Input in the following format:

N

Output

Print the number of the positive divisors of N!, modulo 10^9+7.

Sample Input 1

3

Sample Output 1

4

There are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.

Sample Input 2

6

Sample Output 2

30

Sample Input 3

1000

Sample Output 3

972926972



Sample input:
3


Sample output:
4

Submission status: Accepted

Solution code:
import math
 
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append([b, e])
        b, e = b + 1, 0
    if n > 1:
        fct.append([n, 1])
    return fct
 
n = int(input())
mod = 10 ** 9 + 7
 
l = [0] * (n + 1)
 
for i in range(1, n + 1):
  soi = factorize(i)
  for j in range(len(soi)):
    l[soi[j][0]] += soi[j][1]
 
ans = 1
for i in range(1, n + 1):
  ans = ans * (l[i] + 1) % mod
 
print(ans)

Submission status: Accepted

Solution code:
mod = 1000000000 + 7
 
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr
 
n = int(input())
dat = [0] * 2000 # 約数として求められたある数の合計
 
# N! の各要素の素因数分解をする
res = 1
for i in range(1, n + 1):
    d = factorization(i)
    for j in range(len(d)):
        dat[d[j][0]] += d[j][1]
 
for i in range(2, n + 1):
    res *= (dat[i] + 1)
    res %= mod
 
print(res)

Submission status: Accepted

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n = int(input())
    p = sieve_of_eratosthenes(n+1)
    ansdict = defaultdict(int)
    for i in range(1,n+1):
        for j in p:
            subans = 0
            while i % j == 0:
                ansdict[j] += 1
                i //= j
    ans = 1
    for i in ansdict.values():
        ans *= i+1
        ans %= Mod

    print(ans)
if __name__ == "__main__":
    main() 
    
#endline===============================================

Submission status: Accepted

Solution code:
mod = 1000000000 + 7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

n = int(input())
dat = [0] * 2000

res = 1
for i in range(1, n + 1):
    d = factorization(i)
    for j in range(len(d)):
        dat[d[j][0]] += d[j][1]

for i in range(2, n + 1):
    if dat[i] == 0:
        continue
    #print(dat[i])
    res *= (dat[i] + 1)
    res %= mod

print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict
def primeFactors(n):
    res = []
    while n%2==0:
        res.append(2)
        n //= 2
    x = 3
    while n>1 and n>=x*x:
        while n%x==0:
            res.append(x)
            n //= x
        x += 2
    if n>1:
        res.append(n)
    return res

def modpow(a,n,m):
    res = 1
    while n>0:
        if n%2==1:
            res = (res * a) % m
        a = (a*a) % m
        n = n//2
    return res

MOD = 10**9 + 7
n = int(input())
d = defaultdict(int)
for i in range(1,n+1):
    for r in primeFactors(i):
        d[r] += 1

res = 1
for k in d.keys():
    res *= (d[k]+1)
    res %= MOD
print(res)

Submission status: Accepted

Solution code:
def prime_factorization(N):
	'''
	return: [[2,3], [3,5]] (2^3 * 3^5)
	        [] if N==1
	O(sqrt{N}) (maybe)
	'''
	ans = []
	cnt=0
	while N%2==0:
		cnt+=1
		N//=2
	if cnt!=0:
		ans.append([2,cnt])

	f = 3
	while f*f<=N:
		cnt=0
		while N%f==0:
			N//=f
			cnt+=1
		if cnt!=0:
			ans.append([f,cnt])
		f+=2
	if N!=1:
		ans.append([N,1])
	return ans


N = int(input())
d = {}

for i in range(2,N+1):
	T = prime_factorization(i)
	for t in T:
		if t[0] not in d:
			d[t[0]] = t[1]
		else:
			d[t[0]] += t[1]
ans = 1
mod = 10**9+7
for i in d:
	ans = (ans*(d[i]+1))%mod

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
s, ans, num = 1, 1, 2
for i in range(2, n+1):
  s *= i
l = []
while s != 1:
  if not s % num:
    l.append(num)
    s //= num
  else:
    num += 1
for i in set(l):
  ans *= l.count(i)+1
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
MOD = 10**9 + 7


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


N = int(input())
ans = 1
for prime in primes(N):
    count = 0
    for i in range(1, N + 1):
        while not i % prime:
            count += 1
            i /= prime

    ans *= (count + 1)

print(ans % MOD)

Submission status: Accepted

Solution code:
x = int(input())
p_list = {}

# nの素因数のリストを作るn=4で[2,2]
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

# 階乗なので1からxまでやる
for i in range(1,x+1):
  #print("------------i, prime_factors(i)", i, prime_factors(i))
  # iの素因数を何がいくつあるかカウントしていくi=4で[2,2]でp_list[2]=2
  for k in prime_factors(i):
    p_list[k] = p_list.get(k, 0) + 1
    #print("===i, k:", i, k)
    #print("p_list[k], p_list.get(k, 0):", p_list[k], p_list.get(k, 0))
#print("=======")
#print("p_list", p_list)


divn = 1e9+7
ans = 1
# 素因数の数に1を足して乗じていく(約数の数)
for k in p_list.keys():
    ans *= p_list[k] + 1
    ans = ans % divn

print(int(ans))

Submission status: Accepted

Solution code:
import math
from collections import defaultdict

N = int(input())
MOD = 10**9+7

d = defaultdict(int)
d[1] = 0

for i in range(2, N+1):
    for j in range(2, N+1):
        while i % j == 0:
            i //= j
            d[j] += 1

ans = 1
for i in d.values():
    ans = (ans*(i+1)) % MOD
print(ans)

Submission status: Accepted

Solution code:

N=int(input())
MOD=10**9 + 7
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return divisors
t=1
l=[]
x=dict()
ans=1
for i in range(1,N+1):
    t=t*i
    a=make_divisors(i)
    for j in range(len(a)):
        if a[j] in x:
            x[a[j]]=0
        else:
            x[a[j]]=0
for idx in x:
    a=make_divisors(idx)
    if len(a)==2:
        l.append(idx)


for i in range(1,N+1):
    n=i
    for j in range(len(l)):
        count=0
        while(1):
            if n%l[j]==0:
                n=n//l[j]
                count+=1
            else:
                break
        x[l[j]]+=count
for idx in x:
    if x[idx]!=0:
        ans=ans*(x[idx]+1)

ans=ans%MOD
print(ans)

Submission status: Accepted

Solution code:
import math

N = int(input())

d = {}

def primeFactor(n):
    for i in range(2, int(math.sqrt(n)) + 1):
        while n % i == 0:
            d[i] += 1
            n = n // i
    if n != 1:
        if n in d.keys():
            d[n] += 1
        else:
            d[n] = 1
    #return d

ans = 1
mod = 10**9 + 7

for i in range(1, N + 1):
    primeFactor(i)

for v in d.values():
    ans *= (v + 1) 
    ans %= mod

print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N = int(input())
    mod = 1000000007

    if N == 1:
        print(1)
        exit()

    p = defaultdict(int)
    for i in range(1, N+1):
        d = 2
        j = int(i**0.5)
        while d <= j:
            while i % d == 0:
                p[d] += 1
                i //= d
            d += 1
        if i != 1:
            p[i] += 1

    ans = 1
    for k in p.values():
        ans = (ans * (k+1))%mod
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

n = int(input())
insu = []
for i in range(2, n+1):
  insu = insu + prime_decomposition(i)
insu_c = Counter(insu)

r = 1
mod = 10**9 + 7
for c in insu_c.values():
  r *= (c+1)
  r %= mod
print(r)

Submission status: Accepted

Solution code:
from collections import Counter
mod = 10**9+7
n = int(input())

li = []
def prime_factor(n):
    L = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            L.append(i)
            n = n//i
    if n != 1:
        L.append(n)
    return L

for i in range(2,n+1):
    li.extend(prime_factor(i))

L = Counter(li)
ans = 1
for k,v in L.items():
    ans *=(v+1)%mod
print(ans%mod)

Submission status: Accepted

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
x=int(input())
from collections import Counter
retl=[]
for i in range(1,x+1):
    tmp=prime_factorize(i)
    retl+=tmp
    
f=(Counter(retl))
ret=1
mod=10**9+7
for j in f.values():
    ret*=(j+1)
    ret%=mod
    
print(ret)

Submission status: Accepted

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            return i, n//i
    return n, 1

from collections import Counter
mod = 10**9+7
n = int(input())
f = 1
d = Counter()
div = {}
for i in range(2,n+1):
    a,b = make_divisors(i)
    c,e = Counter(), Counter()
    if a > 1:
        c.update({a:1} if a not in div else div[a])
    if b > 1:
        e.update({b:1} if b not in div else div[b])
    div[i] = c + e
    d.update(div[i])

# print(d)
ans = 1
for v in d.values():
    ans = ans * (v+1) % mod
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def get_prime_factors(n):
    factors = []

    while n % 2 == 0:
        factors.append(2)
        n //= 2

    div = 3
    while n != 1:
        while n % div == 0:
            factors.append(div)
            n //= div
        div += 2

    return factors


N = int(input())
MOD = int(1e9 + 7)
primes = defaultdict(lambda: 0)
for i in range(1, 1 + N):
    for f in get_prime_factors(i):
        primes[f] += 1
ans = 1
for val in primes.values():
    ans *= val + 1
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
#ABC052-C

N = int(input())

fact = {}
for i in range(1, N+1):
    tmp = i
    w = 2
    while tmp != 1:
        if tmp % w == 0:
            add = w
            tmp //= w
        elif w**2 > tmp:
            add = tmp
            tmp = 1
        else:
            w += 1
            continue
        if add in fact:
            fact[add] += 1
        else: fact[add] = 1
ans = 1
for k in fact.values():
    ans = ans*(k+1)%(10**9 + 7)
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

n = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


factors = defaultdict(int)
for i in range(1, n + 1):
    ps = prime_factorize(i)
    for p in ps:
        factors[p] += 1

count = 1
for p, m in factors.items():
    count *= (1 + m)
    count %= 1000000007

print(count)

Submission status: Accepted

Solution code:
import collections

n = int(input())


def prime_factorize_n(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


k = []
for i in range(1, n + 1):
    k = k + prime_factorize_n(i)
c = collections.Counter(k)
d = c.most_common()
ans = 1

for k, v in d:
    ans = (ans*(v + 1)) % (10 ** 9 + 7)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

import math

def prime_factorize(n):
  a = []
  while n % 2 == 0:
    a.append(2)
    n //= 2
  f = 3
  while f*f <= n:
    if n % f == 0:
      a.append(f)
      n //= f
    else:
      f += 2
  if n != 1:
    a.append(n)
  return a

def make_divisors(n):
  divisors = []
  mod = 10**9 + 7
  s = (n**0.5)%mod
  for i in range(1, int(s)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  return divisors

p = []
for i in range(1, n+1):
  p += prime_factorize(i)

import collections
pc = collections.Counter(p)

a = 1
for v, c in pc.items():
  a *= c+1

mod = 10**9 +7
print(a%mod)

Submission status: Accepted

Solution code:
N=int(input())
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  if arr==[]:
    arr.append([n, 1])

  return arr

if N==1:
  print(1)
  exit()
else:
  D=[0]*(N+1)
  for i in range(2,N+1):
    A=factorization(i)
    for j in A:
      D[j[0]]+=j[1]
  ans=1
  for i in D:
    ans*=(i+1)
    ans%=10**9+7
  print(ans)

Submission status: Accepted

Solution code:
import math
from collections import Counter
N = int(input())

def factorize(n):
  cnt = Counter()

  for i in range(2, int(math.sqrt(n)) + 2):
    while n % i == 0:
      cnt[i] += 1
      n //= i

  if n > 1:
    cnt[n] += 1

  return cnt

cnts = []
for i in range(1, N+1):
  cnts.append(factorize(i))

base = Counter()
for c in cnts:
  for (key, value) in c.items():
    base[key] += value

ans = 1
for (key, value) in base.items():
  ans *= (1 + value)

mod = 10 ** 9 + 7
print(ans % mod)

Submission status: Accepted

Solution code:
def factorization(n):
    p=2
    fcr=[]
    while p*p<=n:
        while n%p==0:
            fcr.append(p)
            n//=p
        p+=1
    if n>1:
        fcr.append(n)
    return fcr

mod=10**9+7
n=int(input())
l=[]
for i in range(1,n+1):
 l+=factorization(i)

ans=1
for i in set(l):
 ans*=l.count(i)+1
print(ans%mod)

Submission status: Accepted

Solution code:
n=int(input())
def factorization(n):
  primen = []
  degree = []
  primend = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      primen.append(i)
      degree.append(cnt)
      primend.append([i,cnt])
  if temp!=1:
    primen.append(temp)
    degree.append(1)
    primend.append([temp,1])
  if primen==[]:
    primen.append(n)
    degree.append(1)
    primend.append([n,1])
  return primend#primen,degree
pn=[0]*(n+1)
for i in range(1,n+1):
  for j in factorization(i):
    pn[j[0]]+=j[1]
ans = 1
for k in range(2,n+1):
  ans*=(pn[k]+1)%(10**9+7)
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import math
n = int(input())
# n 以下の素数を全部列挙
def eratosthenes(n):
    prime = [2]
    for i in range(2,n+1):
        for j in range(2,math.ceil(i**1/2)+1):
            if i % j == 0: break
            if j == math.ceil(i**1/2): 
                prime.append(i)
    return prime
prime = eratosthenes(n)
#print(prime)
# その素数に対して、n を割っていく
ans = 1
for i in prime:
    div = i
    cnt_div = 0
    while div <= n:
        cnt_div += n // div
        div *= i

    #print(i,cnt_div)
    ans = ans * (1+cnt_div) % (10**9+7)
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
from collections import defaultdict

N = int(input())
factors = defaultdict(int)
for n in range(2, N+1):
    for i in range(2,int(n**.5)+1):
        while n % i == 0:
            n //= i
            factors[i] += 1
    if n > 1:
        factors[n] += 1

ans = 1
for c in factors.values():
    ans *= c + 1
    ans %= 1000000007
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
import math
cnt=defaultdict(lambda:1)
n=int(input())
prime_number='2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 ' \
             '73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 ' \
             '179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 ' \
             '283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 ' \
             '419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541 ' \
             '547 557 563 569 571 577 587 593 599 601 607 613 617 619 631 641 643 647 653 659 ' \
             '661 673 677 683 691 701 709 719 727 733 739 743 751 757 761 769 773 787 797 809 ' \
             '811 821 823 827 829 839 853 857 859 863 877 881 883 887 907 911 919 929 937 941 ' \
             '947 953 967 971 977 983 991 997'
prime=list(map(int,prime_number.split()))
num=math.factorial(n)
for i in range(n):
    if i>=len(prime):
        break
    while num%prime[i]==0:
            num//=prime[i]
            cnt[prime[i]]+=1
ans=1
for i in cnt.values():
    ans*=i
print(ans%(10**9+7))

Submission status: Accepted

Solution code:
# 素因数分解問題
import math
from collections import Counter

N = int(input())
mod = 10**9+7

def prime_factorize(n):
    c = Counter()
    for i in range(2, int(math.sqrt(n))+2):
      while n % i == 0:
        c[i] += 1
        n //= i
    
    if n > 1:
      c[n] += 1
    return c

counters = []
for n in range(1, N+1):
  counters.append(Counter(prime_factorize(n)))

cnt = Counter()
for c in counters:
  for (key, val) in c.items():
    cnt[key] += val
  
ans = 1

for (key, value) in cnt.items():
  ans *= value + 1

print(ans % mod)

Submission status: Accepted

Solution code:
N = int(input())
count = [1]*(N+1)
ans = 1
mod = 10**9+7

for i in range(2,N+1):
    wari = i
    for w in range(2,i+1):
        while wari % w == 0:
            count[w] += 1
            wari /= w

for i in range(N+1):
    ans *= count[i]

print(ans % mod)

Submission status: Accepted

Solution code:
import math

N = int(input())
num_fac = [0 for _ in range(N + 1)]
MOD = 10 ** 9 + 7

if N == 1:
	print(1)
else:
	for i in range(2, N + 1):
		for j in range(2, math.floor(math.sqrt(i)) + 1):
			while i % j == 0:
				i //= j
				num_fac[j] += 1
			if i == 1:
				break
		if i != 1:
			num_fac[i] += 1
	ans = 1		
			
	for i in range(len(num_fac)):
		if num_fac[i] != 0:
			ans *= ((num_fac[i] + 1) % MOD)
			ans %= MOD
	
	print(ans)

Submission status: Accepted

Solution code:
import math

def primeCheck(n):
    if n == 2:
        return n
    else:
        mx = math.ceil(n ** 0.5)
        for i in range(2, mx + 1):
            if n % i == 0:
                return -1
                break
            elif i == mx:
                return n

n = int(input())

fct = []

for i in range(2, n + 1):
    if primeCheck(i) == -1:
        continue
    else:
        mu = 0
        for j in range(1, 20):
            if n >= i ** j:
                mu += n // (i ** j)
            else:
                fct.append(mu)
                break

ans = 1
for k in range(len(fct)):
    ans *= fct[k] + 1

print(ans % (10**9 + 7))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter



def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

def main():
    N = int(input())
    c = Counter()

    for i in range(1, N + 1):
        for j in prime_factors(i):
            c[j] += 1

    ans = 1
    for k in c.keys():
        ans *= (c[k] + 1)

    print(ans % (10 ** 9 + 7))

    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
from collections import Counter
INF = float("inf")

MOD = 1000000007  # type: int


def factorial(n):
    # 試し割りによる素因数分解
    prime_count = Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def solve(N: int):

    primes = Counter()
    for i in range(1, N+1):
        primes += factorial(i)

    tot = 1
    for key in primes:
        tot *= primes[key]+1
        tot %= MOD

    print(tot)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
def factorization(n):
    """
    引数の値を素因数分解したリストを返す

    Parameters
    ----------
    n : int
        素因数分解したい自然数

    Returns
    -------
    retlist : list
        2以上の整数n => [[素因数, 指数], ...]の2次元リスト
    """
    retlist = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            retlist.append([i, cnt])

    if temp!=1:
        retlist.append([temp, 1])

    if retlist==[]:
        retlist.append([n, 1])

    return retlist

n=int(input())
mod=10**9+7
ans=1
d=dd(int)
for i in range(2,n+1):
    a=factorization(i)
    for j in range(len(a)):
        d[a[j][0]]+=a[j][1]

for v in d.values():
    ans*=v+1
    ans%=mod
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def primes(n):
    if n == 1:
        return None

    while n % 2 == 0:
        ps[2] += 1
        n //= 2

    i = 3
    while i <= int(n ** .5) + 1:
        while n % i == 0:
            ps[i] += 1
            n //= i
        i += 2

    if n != 1:
        ps[n] += 1
    return None


N = int(input())
ps = defaultdict(int)

for n in range(1, N + 1):
    primes(n)

ans = 1
MOD = 10 ** 9 + 7
for key in ps:
    ans *= (ps[key] + 1) % MOD
    ans %= MOD

print(ans)

Submission status: Accepted

Solution code:
P=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997]
def main():
    n=int(input())
    mod=10**9+7
    ans=1
    for p in P:
        if p>n: break
        c = 1
        d = p
        while d<=n:
            c += n//d
            d *= p
        ans *= c%mod
    print(ans%mod)    
main()

Submission status: Accepted

Solution code:
import math
import collections

n = int(input())
mod = 10**9+7

def prime_factorize(n: int) -> list:
    a = []

    while n%2 == 0:
        a.append(2)
        n //= 2

    f = 3
    while f*f <= n:
        if n%f == 0:
            a.append(f)
            n //= f
        else:
            f += 2

    if n != 1:
        a.append(n)

    return a

fac = prime_factorize(math.factorial(n))
c = collections.Counter(fac)

ans = 1
for v in c.values():
    ans *= v+1
    ans %= mod

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

L = [0] * (N)

def prime_factorize(n):
  i = 2
  p_nums = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      p_nums.append(i)
    i += 1
  if n > 1:
    p_nums.append(n)
  return p_nums

for i in range(1,N + 1):
  P = prime_factorize(i)
  for j in range(len(P)):
    p = int(P[j])
    L[p - 1] += 1
    
total = 1
    
for i in L:
  if i != 0:
    total *= (i + 1)
    
div = 10 ** 9 + 7
  
print(total % div)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import math
n = math.factorial(int(input()))
fac = prime_factorize(n)
ans = 1
mod = 7 + 10 ** 9
from collections import Counter
c = Counter(fac)
for i in c.values():
    ans *= (i + 1)
    ans %= mod
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
mod = 10**9+7

def factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import defaultdict as dd

d = dd(int)

for i in range(1, N+1):
    a = factorize(i)
    for j in a:
        d[j] += 1

ans = 1
for k, v in d.items():
    ans = ans * (v+1) % mod
print(ans)

Submission status: Accepted

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


MOD = 10**9+7
d = {}
ans = 1
n = int(input())
for i in range(2, n+1):
    x = factorization(i)
    for j in x:
        if j[0] in d:
            d[j[0]] += j[1]
        else:
            d[j[0]] = j[1]
for i in d.values():
    ans *= (i+1)
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
import math
import collections
import functools


def solve():
    N = int(input())
    P = 10**9+7

    if N == 1:
        return 1

    fn = math.factorial(N)

    divisors = prime_factorize(fn)

    c = collections.Counter(divisors)

    ans = functools.reduce(lambda x, y: x * y, map(lambda x: x + 1, c.values()))

    return ans % P


def prime_factorize(n):
    res = []
    while n % 2 == 0:
        res.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            res.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        res.append(n)
    return res


if __name__ == '__main__':
    res = solve()
    print(res)

Submission status: Accepted

Solution code:
from math import factorial
from collections import Counter
MOD = 10 ** 9 + 7

def prime_decomposition(n):
 i = 2
 table = []
 while i * i <= n:
   while n % i == 0:
     n //= i
     table.append(i)
   i += 1
 if n > 1:
   table.append(n)
 return table

n = int(input())
nn = factorial(n)
nnn = Counter(prime_decomposition(nn))

ans = 1
for i in nnn.values():
    ans *= i + 1
    ans %= MOD

print(ans)

Submission status: Accepted

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


N = int(input())

prime_dict = dict()
for i in range(1, N+1):
    primes = factorization(i)
    for j in range(len(primes)):
        if primes[j][0] in prime_dict:
            prime_dict[primes[j][0]] += primes[j][1]
        else:
            prime_dict[primes[j][0]] = primes[j][1]
            
ans = 1
for k, v in prime_dict.items():
    if k != 1:
        ans *= v+1

print(ans % (10**9+7))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
from collections import Counter
n=int(input())
p=Counter()
for i in range(1,n+1):
    p.update(Counter(prime_factorize(i)))
#print(p)
ans=1
for i in p.values():
    ans*=i+1
    ans%=10**9+7
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

from collections import Counter

MOD = 10**9+7

def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            res.append(i)
            n //= i
    if n != 1:
        res.append(n)
    return res

prime_fac = []
for i in range(1, N+1):
    prime_fac.extend(prime_factorize(i))

c = Counter(prime_fac)

ans = 1
for v in c.values():
    ans *= v+1
    ans %= MOD
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
 
N = int(input())
MOD = 10**9+7
mp = defaultdict(int)
for i in range(2, N+1) :
  x = i
  for j in range(2, x+1): 
    while x%j == 0:
      x /= j
      mp[j] += 1
      
ans = 1
for v in mp.values():
  ans = (ans * (v+1)) % MOD
print(ans)